| | |
Emergency help, my assignment is due in 24hours
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Mar 2005
Posts: 3
Reputation:
Solved Threads: 0
The Acme Software Company sells its "Adding Tutor" software for $109.Quantity discount are given using the following table:
Quantity Discount
10-19 20%
20-49 30%
50-99 40%
100 or more 50%
Write a program that asks for the number of units sold and calculates the total cost of the purchase including discount. Adjust the totalby the sales tax (use 7.75%). Display the total cost, the discount, the sales tax and adjusted amount due. Display a warning and end the program if the number of units sold isnot greater than 0
I have finish but I couldn't calculate and it not work..Can anyone help me please
Quantity Discount
10-19 20%
20-49 30%
50-99 40%
100 or more 50%
Write a program that asks for the number of units sold and calculates the total cost of the purchase including discount. Adjust the totalby the sales tax (use 7.75%). Display the total cost, the discount, the sales tax and adjusted amount due. Display a warning and end the program if the number of units sold isnot greater than 0
I have finish but I couldn't calculate and it not work..Can anyone help me please
•
•
Join Date: Mar 2005
Posts: 3
Reputation:
Solved Threads: 0
This is what I got so far. Plese help out. I don't know how to do it. I really need help.
C++ Syntax (Toggle Plain Text)
//PREPROCESSOR DIRECTIVE # include <iostream> //FOR CIN AND COUT # include <iomanip> # include <string> using namespace std; //Main Function int main() { //Define Variables int Quantity; // QUANTITY OF ITEMS float Cost; // SALES ITEMS float Discount; // DISCOUNT MONEY float TaxRate; // SALE TAXES float TotalCost; // TOTAL AMOUNT FOR EACH ITEM float AdjustAmount; // THE AMOUNT DUE //DEFINE CONSTANTS const double DiscountRate1= 0.00f; //Rate CODES const double DiscountRate2= 0.20f; const double DiscountRate3 = 0.30f; const double DiscountRate4 = 0.40f; const double DiscountRate5 = 0.50f; cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(2); cout << "\n\nThe Acme Software Company"; //PROGRAM TITLE cout << "\nby Kristen Ngoc, Nguyen"; //PROGRAM AUTHOR //ASK USER FOR THE AMOUNT OF UNITS YOU WANT TO PURCHASE cout << "\n\nPlease enter the units you want to purchase:"; //INPUT DATA FOR UNITS cin >> Quantity; //TEST IF QUANTITY IS GREATER THAN 0 if (Quantity >= 0) { //DETERMINE THE DISCOUNT RATE if (Quantity <10 ) { Cost = Quantity * 109; Discount = Cost * DiscountRate1; TotalCost = Cost - Discount; TaxRate = TotalCost *0.0775f; AdjustAmount = TotalCost + TaxRate; } else if (Quantity <20) { Cost = Quantity * 109; Discount = Cost * DiscountRate2; TotalCost = Cost - Discount; TaxRate = TotalCost *0.0775f; AdjustAmount = TotalCost + TaxRate; } else if (Quantity <50) { Cost = Quantity * 109; Discount = Cost * DiscountRate3; TotalCost = Cost - Discount; TaxRate = TotalCost *0.0775f; AdjustAmount = TotalCost + TaxRate; } else if (Quantity <100) { Cost = Quantity * 109; Discount = Cost * DiscountRate4; TotalCost = Cost - Discount; TaxRate = TotalCost *0.0775f; AdjustAmount = TotalCost + TaxRate; } else { Cost = Quantity * 109; Discount = Cost * DiscountRate5; TotalCost = Cost - Discount; TaxRate = TotalCost *0.0775f; AdjustAmount = TotalCost + TaxRate; } //DISPLAY RESULTS cout << fixed << showpoint << setw (20); cout <<"\nSales Results\n"; cout <<"- - - - - - - - - - \n"; cout <<"\n" << setw(20) << "Cost $" << "Cost" << endl; cout <<"\n" << setw(20) << "Discount rate " << "DiscountRate" << endl; cout <<"\n" << setw(20) << "Discount $" << "Discount" << endl; cout <<"\n" << setw(20) << "Total Cost $" << "TotalCost" << endl; cout <<"\n" << setw(20) << "Sales Taxes $" << "TaxRate" << endl; cout <<"\n" << setw(20) << "Adjust Amount $" << "AdjustAmount" << endl; } else cout << "Invalid entry\n"; return 0; }
Last edited by alc6379; Mar 21st, 2005 at 4:05 pm. Reason: added [code] tags
In all cases remove quotes around bolded section Declare DiscountRate in your application and set its value inside each conditional
As you've gotten it 95% right, I will post a modified version of this app that you can use as a reference. Don't use it as your assignment or your instructor may get you to explain why you did it that way.
cout <<"\n" << setw(20) << "Adjust Amount $" << "AdjustAmount" << endl; C++ Syntax (Toggle Plain Text)
cout <<"\n" << setw(20) << "Discount rate " << DiscountRate << endl;
As you've gotten it 95% right, I will post a modified version of this app that you can use as a reference. Don't use it as your assignment or your instructor may get you to explain why you did it that way.
Ok as promised here is my modification based on your algorithym Basically all I did with your code is eliminate redundancy. Only have conditionals do what they need to rather than duplicate the same code over and over again.
C++ Syntax (Toggle Plain Text)
# include <iostream> # include <iomanip> # include <string> using namespace std; int main() { int Quantity, Disc; double Cost, Discount, SalesTax; cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(2); cout << "\n\nThe Acme Software Company\nby Kristen Ngoc, Nguyen"; //PROGRAM AUTHOR do { cout << "\n\nPlease enter the units you want to purchase: "; //INPUT DATA FOR UNITS cin >> Quantity; if (Quantity == 0) break; Cost = 109.0 * Quantity; if (Quantity < 10) Disc = 0; else if (Quantity < 20) Disc = 20; else if (Quantity < 50) Disc = 30; else if (Quantity < 100) Disc = 40; else Disc = 50; cout << fixed << showpoint << setw (20); cout <<"\nSales Results\n"; cout <<"- - - - - - - - - - \n"; cout << setw(20) << "Cost" << setw(25) << Cost << endl; Discount = Cost * (double (Disc) / 100.0); cout << setw(20) << "Less" << setw(25) << Discount << " " << Disc << "%" << endl; cout << setw(20) << "Total Cost" << setw (25) << Cost - Discount << endl; SalesTax = (Cost - Discount) * .0775; cout << setw(20) << "7.75% Sales Tax" << setw (25) << SalesTax << endl; cout << setw (45) << "_________________" << endl; cout << setw(20) << "Total" << setw (25) << Cost - Discount + SalesTax << endl; } while (1); return 0; }
Please don't label your thread as Urgent-- it implies that your problem is more important than others. Help is given here on a first-come, first-served basis.
http://www.catb.org/~esr/faqs/smart-...ns.html#urgent
http://www.catb.org/~esr/faqs/smart-...ns.html#urgent
Alex Cavnar, aka alc6379
![]() |
Similar Threads
- C++ Emergency (C++)
- assignment help (Database Design)
- Need help with an assignment that is due tomorrow plzzzz (C++)
Other Threads in the C++ Forum
- Previous Thread: Detecting garbage inputs
- Next Thread: Best free C/C++ compiler for a newbie?
Views: 2071 | Replies: 6
| Thread Tools | Search this Thread |
Tag cloud for C++
api array arrays based beginner binary bmp c++ c/c++ calculator char class classes code compile compiler console conversion convert count data delete deploy dll download dynamic encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int java lib library lines linkedlist linker list loop looping loops map math matrix memory microsoft newbie news number output pointer problem program programming project python random read recursion recursive reference return simple sort spoonfeeding string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio void win32 windows winsock wordfrequency wxwidgets






