Server IP : 172.16.15.8 / Your IP : 18.216.145.37 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/bmmassie/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
//-------------------------------------------------------------------------- // Test Problem // // Written by B M Massie // October 2008 // // Purpose: To calculate the proper savings, display both the savings and // the amount owed after savings, and to print the name of the gift // for which the customer is registered. //-------------------------------------------------------------------------- // ----------- Preprocessor Section ----------- #include <iostream> #include <iomanip> using namespace std; // --------------- Main Function --------------- int main () { // ----- Variables and Constants float purchase, // amount of purchase savings, // amount saved with the discount amountowed; // amount owed after savings // ----- Input Phase cout << "\n\n Enter the amount of your purchase --> "; cin >> purchase; // ----- Processing Phase if (purchase <= 50) { savings = purchase * .10; amountowed = purchase - savings; } else if ( purchase > 50 && purchase <= 250) { savings = (purchase - 50) + .15 + 5; amountowed = purchase - savings; } else if (purchase > 250) { savings = (purchase -250) + .2 + 35; amountowed = purchase - savings; } // ----- Output Phase cout << fixed << setprecision (2); // force fixed point format for floats cout << "\n\n********************************************"; cout << "\n Sales Report "; cout << "\n**********************************************"; cout << "\n\n How much you saved " << setw(10) << savings << endl; cout << "\n This is what you owe " << setw(10) << amountowed << endl; cout << "\n Your Recieve a free "; if (purchase <= 50) cout << " Electric Knife!" << endl; else if (purchase > 50 && purchase <= 250) cout << "Blender!" << endl; else cout << " Toster Oven!" << endl; return 0; }