Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 3.142.53.151
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/pswoodson/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : //home/pswoodson/gas.cpp
//---------------------------------------------------------------------//
// Programming Assignment 2
//
// Calculate the cost of gasoline, the price of a wash, the total cost, 
//    and the number of discount points earned.
//
// Written by Paula S. Woodson
// September 26, 2008                                              
//-----------------------------------------------------------------------//

//------ Preprocessor Section

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

//------ Main Function

int main()
{

//------ Variables


int
  intgallons;     // amount of gallons without decimal 

float
   costofgas,    // cost of the gasoline
   gallons,      // amount of gallons
   totalcost,    // cost of gasoline and the wash
   numofdis,     // number of discount points
   carwash;      // car wash

            
char
   typeofgas;    // types of differnt gasoline


// Input

cout << "\n\n---------Welcome to VWC Service Station and Car Wash!-----------\n\n";

cout << "Enter Amount You want: ";
cin >>  gallons;
cout << endl;

cout << "Enter Grade (P for Premium,R for Regular, S for Super)";
cin >> typeofgas;  
cout << endl;

//--------- Processing Phase

if (typeofgas == 'P' || typeofgas == 'p')
   costofgas= 3.539 * gallons;
  else if (typeofgas == 'R' || typeofgas == 'r')
   costofgas = 3.339 * gallons;
   else if (typeofgas == 'S' || typeofgas == 's')
   costofgas = 3.679 * gallons;

intgallons=static_cast<int>(gallons);

if(intgallons == 6)
   carwash = .10 * 6.00;
 else if (intgallons == 7)
   carwash = .20 * 6.00; 
 else if (intgallons == 8)
   carwash = .30 * 6.00;
 else if (intgallons == 9) 
   carwash = .40 * 6.00;
 else if (intgallons == 10)
   carwash = .50 * 6.00;
 else if (intgallons == 11)
   carwash = .60 * 6.00;
 else if (intgallons == 12)
   carwash = .70 * 6.00;
  else if (intgallons == 13)
   carwash = .80 * 6.00;
 else if (intgallons == 14)
   carwash = .90 * 6.00;
 else if (intgallons >= 15)
 { carwash = 0;
//   cout << "Car Wash Free";
 }
totalcost = carwash + costofgas;

if(typeofgas == 'P'||typeofgas == 'p')
      numofdis = 3 * intgallons;
else if((typeofgas == 'R')||( typeofgas == 'r'))
        numofdis = 4 * intgallons;
    else if ((typeofgas == 'S')||(typeofgas == 's'))
        numofdis = 5 * intgallons;
//-------output

cout<< fixed;              // force fixed point format
cout<< setprecision(2);   // force results to look like dollars & cents
cout<< "\n\n ***************************************************";
cout<< "\n\n Amount Of Gas                 "<< gallons   << "\n\n";
cout<< "\n   Grade Purchased:              ";
if((typeofgas == 'P') ||(typeofgas == 'p'))
  cout<< "Premium";
if((typeofgas == 'R') ||(typeofgas == 'r'))
  cout<< "Regular";
if((typeofgas == 'S') ||(typeofgas == 's'))
  cout<< "Super";
cout<< "\n\n Cost of Gasoline:            $"<< costofgas <<"\n\n";
cout<< "\n\n Car Wash:                    $"<< carwash<<"\n\n";
if(carwash==0.00)
cout<< "                                       Car Wash Free";
cout<< "\n\n Total Cost:                  $"<< totalcost <<"\n\n";
cout<< "\n\n Number of Discount Point:     "<< numofdis  <<"\n\n";
 
return 0 ;
}

Stv3n404 - 2023