Server IP : 172.16.15.8 / Your IP : 18.118.119.77 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/../cchansen/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
// --------------------------------------------------------------------- // Program # 2 - The VWC Sevice Station and Car Wash // // Written by Caitlin Hansen // September 2008 // // Purpose: To calculate the cost of the gasoline, the price of a wash, // the total cost for the gasoline and car wash, and the number of // discount points earned. //---------------------------------------------------------------------- // ------ Preprocessor Section ------ # include <iostream> # include <iomanip> # include <cmath> using namespace std; // --------- Main Function ---------- int main () { // ------ Variables and Constants int discpts; // the number of discount points earned float R, // the price of a gallon of the regular (R) gasoline P, // the price of a gallon of the premium (P) gasoline S, // the price of a gallon of the premium (S) gasoline gasamt, // the amount of gallons of gasoline pumped discwash, // the discounted price of the car wash orgwash, // the orginial price of the car wash amtspent, // the amount spent on the gallons of gasoline totcost; // the total cost of the gas and car wash char gastype; // the type of gasoline bought, R, P, or S // ------ Input Phase cout << endl; cout << "Welcome to the VWC Service Station Analysis Program!"; cout << endl; cout << endl; cout << "Enter the type of gasoline pumped (R for regular, P for premium, or S for super) --------> "; cin >> gastype; cout << endl; cout << "Enter the amount of gasoline pumped ------> "; cin >> gasamt; cout << endl; cout << endl; // ------ Processing Phase orgwash = 6.00; if(gasamt <= 5) discwash = orgwash; else if(gasamt <= 6) discwash = orgwash - (0.10 * orgwash); else if(gasamt <= 7) discwash = orgwash - (0.20 * orgwash); else if(gasamt <= 8) discwash = orgwash - (0.30 * orgwash); else if(gasamt <= 9) discwash = orgwash - (0.40 * orgwash); else if(gasamt <= 10) discwash = orgwash - (0.50 * orgwash); else if(gasamt <= 11) discwash = orgwash - (0.60 * orgwash); else if(gasamt <= 12) discwash = orgwash - (0.70 * orgwash); else if(gasamt <= 13) discwash = orgwash - (0.80 * orgwash); else if(gasamt <= 14) discwash = orgwash - (0.90 * orgwash); else discwash = 0.00; if(gastype == 'R' || gastype == 'r') amtspent = gasamt * 3.399; else if(gastype == 'P' || gastype == 'p') amtspent = gasamt * 3.539; else amtspent = gasamt * 3.679; totcost = amtspent + discwash; if(gastype == 'R' || gastype == 'r') discpts = static_cast<int>(gasamt) * 3; else if(gastype == 'P' || gastype == 'p') discpts = static_cast<int>(gasamt) * 4; else if(gastype == 'S' || gastype == 's') discpts = static_cast<int>(gasamt) * 5; // ------ Output Phase cout << fixed; // force fixed point format for floats cout << " *~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*"; cout << endl; cout << " *~*~*~*~*~* VWC Service Station Savings Summary *~*~*~*~*~*~*"; cout << endl; cout << " *~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*"; cout << endl; cout << endl; cout << setprecision(2); // four decimal digit for floats cout << " Gasoline Pumped: " << gasamt; cout << endl; cout << endl; cout << " Type of Gasoline: "; if(gastype == 'R' || gastype == 'r') cout << "Regular"; else if(gastype == 'P' || gastype == 'p') cout << "Premium"; else cout << "Super"; cout << endl; cout << endl; cout << " Amount Spent on Gasoline: " << amtspent; cout << endl; cout << endl; cout << " Price of Discounted Car Wash: $ " << discwash; if(discwash == 0) cout << " It's FREE!"; cout << endl; cout << endl; cout << " Total Cost of Gasoline and Car Wash: $ " << totcost; cout << endl; cout << endl; cout << " Amount of Discount Points Earned: " << discpts; cout << endl; cout << endl; if(discpts >= 1) {cout << " Congratulations!"; cout << endl; cout << endl; cout << " ***You've earned discount points with yours purchases today"; cout << endl; cout << " These points may be used towards purchases not only in the"; cout << endl; cout << " service station, but the adjacent convenience store as well!***"; cout << endl; } return 0; }