Emergency help, my assignment is due in 24hours

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2005
Posts: 3
Reputation: purplefantasy is an unknown quantity at this point 
Solved Threads: 0
purplefantasy purplefantasy is offline Offline
Newbie Poster

Emergency help, my assignment is due in 24hours

 
1
  #1
Mar 20th, 2005
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
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 199
Reputation: Tight_Coder_Ex is an unknown quantity at this point 
Solved Threads: 14
Tight_Coder_Ex's Avatar
Tight_Coder_Ex Tight_Coder_Ex is offline Offline
Junior Poster

Re: Emergency help, my assignment is due in 24hours

 
1
  #2
Mar 20th, 2005
Originally Posted by purplefantasy
I have finish but I couldn't calculate and it not work
Show us what you've got done so far, so we know what to tell you to correct.
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 3
Reputation: purplefantasy is an unknown quantity at this point 
Solved Threads: 0
purplefantasy purplefantasy is offline Offline
Newbie Poster

Re: Emergency help, my assignment is due in 24hours

 
0
  #3
Mar 20th, 2005
This is what I got so far. Plese help out. I don't know how to do it. I really need help.
  1. //PREPROCESSOR DIRECTIVE
  2. # include <iostream> //FOR CIN AND COUT
  3. # include <iomanip>
  4. # include <string>
  5.  
  6. using namespace std;
  7.  
  8. //Main Function
  9.  
  10. int main()
  11.  
  12. {
  13. //Define Variables
  14. int Quantity; // QUANTITY OF ITEMS
  15.  
  16. float Cost; // SALES ITEMS
  17. float Discount; // DISCOUNT MONEY
  18. float TaxRate; // SALE TAXES
  19. float TotalCost; // TOTAL AMOUNT FOR EACH ITEM
  20. float AdjustAmount; // THE AMOUNT DUE
  21.  
  22. //DEFINE CONSTANTS
  23. const double DiscountRate1= 0.00f; //Rate CODES
  24. const double DiscountRate2= 0.20f;
  25. const double DiscountRate3 = 0.30f;
  26. const double DiscountRate4 = 0.40f;
  27. const double DiscountRate5 = 0.50f;
  28.  
  29. cout.setf(ios::fixed);
  30. cout.setf(ios::showpoint);
  31. cout.precision(2);
  32.  
  33. cout << "\n\nThe Acme Software Company"; //PROGRAM TITLE
  34. cout << "\nby Kristen Ngoc, Nguyen"; //PROGRAM AUTHOR
  35.  
  36. //ASK USER FOR THE AMOUNT OF UNITS YOU WANT TO PURCHASE
  37.  
  38. cout << "\n\nPlease enter the units you want to purchase:"; //INPUT DATA FOR UNITS
  39. cin >> Quantity;
  40.  
  41. //TEST IF QUANTITY IS GREATER THAN 0
  42. if (Quantity >= 0)
  43. {
  44. //DETERMINE THE DISCOUNT RATE
  45.  
  46. if (Quantity <10 )
  47. {
  48.  
  49. Cost = Quantity * 109;
  50. Discount = Cost * DiscountRate1;
  51. TotalCost = Cost - Discount;
  52. TaxRate = TotalCost *0.0775f;
  53. AdjustAmount = TotalCost + TaxRate;
  54. }
  55.  
  56. else if (Quantity <20)
  57. {
  58.  
  59. Cost = Quantity * 109;
  60. Discount = Cost * DiscountRate2;
  61. TotalCost = Cost - Discount;
  62. TaxRate = TotalCost *0.0775f;
  63. AdjustAmount = TotalCost + TaxRate;
  64. }
  65. else if (Quantity <50)
  66. {
  67.  
  68. Cost = Quantity * 109;
  69. Discount = Cost * DiscountRate3;
  70. TotalCost = Cost - Discount;
  71. TaxRate = TotalCost *0.0775f;
  72. AdjustAmount = TotalCost + TaxRate;
  73. }
  74. else if (Quantity <100)
  75. {
  76.  
  77. Cost = Quantity * 109;
  78. Discount = Cost * DiscountRate4;
  79. TotalCost = Cost - Discount;
  80. TaxRate = TotalCost *0.0775f;
  81. AdjustAmount = TotalCost + TaxRate;
  82. }
  83. else
  84. {
  85.  
  86. Cost = Quantity * 109;
  87. Discount = Cost * DiscountRate5;
  88. TotalCost = Cost - Discount;
  89. TaxRate = TotalCost *0.0775f;
  90. AdjustAmount = TotalCost + TaxRate;
  91.  
  92. }
  93.  
  94.  
  95.  
  96. //DISPLAY RESULTS
  97.  
  98. cout << fixed << showpoint << setw (20);
  99. cout <<"\nSales Results\n";
  100. cout <<"- - - - - - - - - - \n";
  101. cout <<"\n" << setw(20) << "Cost $" << "Cost" << endl;
  102. cout <<"\n" << setw(20) << "Discount rate " << "DiscountRate" << endl;
  103. cout <<"\n" << setw(20) << "Discount $" << "Discount" << endl;
  104. cout <<"\n" << setw(20) << "Total Cost $" << "TotalCost" << endl;
  105. cout <<"\n" << setw(20) << "Sales Taxes $" << "TaxRate" << endl;
  106. cout <<"\n" << setw(20) << "Adjust Amount $" << "AdjustAmount" << endl;
  107.  
  108. }
  109.  
  110. else
  111.  
  112. cout << "Invalid entry\n";
  113. return 0;
  114. }
Last edited by alc6379; Mar 21st, 2005 at 4:05 pm. Reason: added [code] tags
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 199
Reputation: Tight_Coder_Ex is an unknown quantity at this point 
Solved Threads: 14
Tight_Coder_Ex's Avatar
Tight_Coder_Ex Tight_Coder_Ex is offline Offline
Junior Poster

Re: Emergency help, my assignment is due in 24hours

 
0
  #4
Mar 20th, 2005
In all cases remove quotes around bolded section
cout <<"\n" << setw(20) << "Adjust Amount $" << "AdjustAmount" << endl;
Declare DiscountRate in your application and set its value inside each conditional
  1. 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.
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 3
Reputation: purplefantasy is an unknown quantity at this point 
Solved Threads: 0
purplefantasy purplefantasy is offline Offline
Newbie Poster

Re: Emergency help, my assignment is due in 24hours

 
0
  #5
Mar 20th, 2005
Can you help me make it look right. Because When I did it. It not show the calculation at all. So I think that's not right so we have to use switch or something. Thanks for you help. It due today. It hard when it run.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 199
Reputation: Tight_Coder_Ex is an unknown quantity at this point 
Solved Threads: 14
Tight_Coder_Ex's Avatar
Tight_Coder_Ex Tight_Coder_Ex is offline Offline
Junior Poster

Re: Emergency help, my assignment is due in 24hours

 
0
  #6
Mar 20th, 2005
Ok as promised here is my modification based on your algorithym
  1. # include <iostream>
  2. # include <iomanip>
  3. # include <string>
  4. using namespace std;
  5. int main()
  6. {
  7. int Quantity, Disc;
  8. double Cost, Discount, SalesTax;
  9. cout.setf(ios::fixed);
  10. cout.setf(ios::showpoint);
  11. cout.precision(2);
  12. cout << "\n\nThe Acme Software Company\nby Kristen Ngoc, Nguyen"; //PROGRAM AUTHOR
  13. do
  14. {
  15. cout << "\n\nPlease enter the units you want to purchase: "; //INPUT DATA FOR UNITS
  16. cin >> Quantity;
  17. if (Quantity == 0)
  18. break;
  19. Cost = 109.0 * Quantity;
  20. if (Quantity < 10)
  21. Disc = 0;
  22. else
  23. if (Quantity < 20)
  24. Disc = 20;
  25. else
  26. if (Quantity < 50)
  27. Disc = 30;
  28. else
  29. if (Quantity < 100)
  30. Disc = 40;
  31. else
  32. Disc = 50;
  33.  
  34. cout << fixed << showpoint << setw (20);
  35. cout <<"\nSales Results\n";
  36. cout <<"- - - - - - - - - - \n";
  37. cout << setw(20) << "Cost" << setw(25) << Cost << endl;
  38. Discount = Cost * (double (Disc) / 100.0);
  39. cout << setw(20) << "Less" << setw(25) << Discount << " " << Disc << "%" << endl;
  40. cout << setw(20) << "Total Cost" << setw (25) << Cost - Discount << endl;
  41. SalesTax = (Cost - Discount) * .0775;
  42. cout << setw(20) << "7.75% Sales Tax" << setw (25) << SalesTax << endl;
  43. cout << setw (45) << "_________________" << endl;
  44. cout << setw(20) << "Total" << setw (25) << Cost - Discount + SalesTax << endl;
  45. } while (1);
  46. return 0;
  47. }
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.
Reply With Quote Quick reply to this message  
Join Date: Dec 2003
Posts: 2,414
Reputation: alc6379 has a spectacular aura about alc6379 has a spectacular aura about alc6379 has a spectacular aura about 
Solved Threads: 123
Team Colleague
alc6379's Avatar
alc6379 alc6379 is offline Offline
Cookie... That's it

Re: Emergency help, my assignment is due in 24hours

 
0
  #7
Mar 21st, 2005
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
Alex Cavnar, aka alc6379
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum


Views: 2071 | Replies: 6
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC