Server IP : 172.16.15.8 / Your IP : 3.133.128.227 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/vnlaughlin/../drsparks/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
//-------------------------------------------------------------------------------------------------------------- // Second Project for Computer Science Class // // Written by Dale Sparks // September 2008 // // Purpose: To Calculate the amount spent on gas, to calculate // the price of the carwash, the total cost amount, // and the total number of discount points. //-------------------------------------------------------------------------------------------------------------- //-----Preprocessing Section----- #include <iostream> #include <iomanip> #include <cmath> using namespace std; // -----Main Function----- int main () { // -----Variables and Broken-Up Equations----- float numgal, //number of gallons of gas purchased cwpr, //price of the car wash after gas totcst, //total cost of car wash and gas gasp; //price of gas per gallon int numgalint, //number of gallons as a whole number pnt; //number of discount points earned char typegas; //type of gas purchased //-----Input Phase----- cout << "-------------===Welcome to the Gas and Car Wash Program===---------------" << endl; cout << "\nType of Gas Purchased(R for Regular, P for Premium, and S for Super) --->"; cin >> typegas; cout << "\nNumber of Gallons Purchased ---------------------------------------->"; cin >> numgal; //-----Processing Phase----- if (typegas == 'R' || typegas == 'r') gasp = numgal * 3.399; else if (typegas == 'P' || typegas == 'p') gasp = numgal * 3.539; else gasp = numgal * 3.679; numgalint = static_cast<int>(numgal); if (numgalint <= 5) cwpr = 6; else if (numgalint < 15) cwpr = 6 - ((numgalint - 5) * .1 * 6); else cwpr = 0; totcst = gasp + cwpr; if (typegas == 'R' || typegas == 'r') pnt = 3 * numgalint; else if (typegas == 'P' || typegas == 'p') pnt = 4 * numgalint; else pnt = 5 * numgalint; //-----Output Phase----- cout << fixed << setprecision(2); if (typegas == 'R' || typegas == 'r') cout << "\nGas Type is: Regular" ; else if (typegas == 'P' || typegas == 'p') cout << "\nGas Type is: Premium"; else cout << "\nGas Type is: Super"; cout << "\nNumber of Gallons Purchased: " << numgal << endl; cout << "\n\nPrice of Gas: " << setw(5) << gasp << endl; cout << "Price of Car Wash: " << setw(5) << cwpr << endl; cout << "Total Cost for Gas and Car Wash: " << setw(5) << totcst << endl; cout << "Number of Discount Points Earned: " << setw(5) << pnt << endl; return 0; }