Server IP : 172.16.15.8 / Your IP : 18.224.31.90 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/jljustice/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
//------------------------------------------------------ // Assignment #2 - Gas Station - // - // Written By : Jared Justice - // Due Date: September 26, 2008 - // - // Purpose: Calculate the price of gas, the price - // of carwash after the discount, and - // number or award points earned - //------------------------------------------------------ // ----Preprocessor Section---- #include <iostream> #include <iomanip> using namespace std; // ----Main Function---- int main () { // ----Variables---- float gallons, // the number of gallons purchased numdis, // the number of discount points recieved carwash = 6.00, // the number you pay for the original wash discount, // actual cost of carwash after discount cost; // price of gas char typegas; // regular, premium, or supreme // ----Input Phase---- cout << "\n Enter number of gallons-----> "; cin >> gallons; cout << "\n Type of gas (r for regular, p for premium, and s for supreme)---->"; cin >> typegas; // ----Processing Phase---- if(typegas == 'r' || typegas == 'R') { cost = 3.399 * gallons, numdis = 3 * static_cast<int>(gallons); } else if (typegas == 'p' || typegas == 'P') { cost = 3.539 * gallons, numdis = 4 * static_cast<int>(gallons); } else if (typegas == 's' || typegas =='S') { cost = 3.679 * gallons, numdis = 5 * static_cast<int>(gallons); } if(gallons <= 5) discount = carwash; else if(gallons <= 6) discount = carwash - (.10 * carwash); else if(gallons <= 7) discount = carwash - (.20 * carwash); else if(gallons <= 8) discount = carwash - (.30 * carwash); else if(gallons <= 9) discount = carwash - (.40 * carwash); else if(gallons <= 10) discount = carwash - (.50 * carwash); else if(gallons <= 11) discount = carwash - (.60 * carwash); else if(gallons <= 12) discount = carwash - (.70 * carwash); else if(gallons <= 13) discount = carwash - (.80 * carwash); else if(gallons <= 14) discount = carwash - (.90 * carwash); else if(gallons <= 15 || gallons >= 15) discount = carwash - (1.00 * carwash); // ----Output Phase---- cout << fixed; cout << setprecision (2); cout << "\n\n Welcome to the VWC gas pump!"; cout << "\n\n This is how much you pay for gas $" << cost; cout << "\n\n Price of Carwash is $ "<< discount; cout << "\n\n Number of award points earned ----> " << numdis; return 0; }