fork download
  1. //OrinTill Qimid CS1A Chapter 4, P. 221, 10
  2. //
  3. /**************************************************************
  4.  * Calculate discount
  5.  *
  6.  * ____________________________________________________________
  7.  * This program will calcualte the discount base on the qunaity of purchase
  8.  * ____________________________________________________________
  9.  * INPUT
  10.  * Purchase : the quanity of purchases
  11.  * OUTPUT
  12.  * discount : the total amount after the discount
  13.  **************************************************************/
  14. #include <iostream>
  15. #include <iomanip>
  16. #include <cmath>
  17. using namespace std;
  18.  
  19. int main()
  20. {
  21. float Purchase,
  22. discount;
  23. cout<<"How many products did you purchase?"<<endl;
  24. cin >> Purchase;
  25. if (Purchase<10)
  26. {
  27. cout << "sorry purchase quanity too small no discount given"<<endl;
  28.  
  29. }
  30. else if (Purchase >= 100)
  31. {
  32. discount = Purchase *99 * 0.50;
  33. cout <<"congraulation you get a 50 percent discount! $"<< discount << " is your total price"<< endl;
  34. }
  35.  
  36.  
  37. else if (Purchase>=50)
  38. {
  39. discount = Purchase *99 * 0.40;
  40. cout <<"congraulation you get a 40 percent discount! $"<< discount << " is your total price"<< endl;
  41. }
  42. else if (Purchase>=20)
  43. {
  44. discount = Purchase *99 * 0.30;
  45. cout <<"congraulation you get a 30 percent discount! $"<< discount << " is your total price"<< endl;
  46. }
  47. else
  48. {
  49. discount = Purchase *99 * 0.20;
  50. cout <<"congraulation you get a 20 percent discount! $"<< discount << " is your total price"<< endl;
  51. }
  52.  
  53.  
  54.  
  55.  
  56. return 0;
  57. }
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
Standard output is empty