fork download
  1. //Max Kichuk CS1A Chapter 4, P. 222, #11
  2. //
  3. /****************************************************************
  4.  *
  5.  * CALCULATES TOTAL POINTS REWARDED TO CUSTOMER
  6.  * ______________________________________________________________
  7.  * Asks the user to enter the number of books
  8.  * they purchases this month. Then displays
  9.  * the number of points they are awarded accordingly.
  10.  * ______________________________________________________________
  11.  *
  12.  * INPUT
  13.  * booksPurchased : number of books customer bought
  14.  *
  15.  * OUTPUT
  16.  * pointsRewarded : points according to number of books bought
  17.  *
  18.  **************************************************************/
  19.  
  20. #include <iostream>
  21. #include <iomanip>
  22. using namespace std;
  23.  
  24. int main() {
  25. //Declaring program variables
  26. int booksPurchased; // INPUT - number of books purchased
  27.  
  28. int pointsRewarded; // OUTPUT - points for booksPurchased
  29.  
  30. // INPUT : Initialize variables
  31. cout << "How many books did you purchase this month?: \n\n";
  32. cin >> booksPurchased;
  33.  
  34. // OUTPUT : checks how many books were purchased and returns points
  35. if (booksPurchased == 0)
  36. {
  37. cout << "You have purchased 0 books this month!\n";
  38. cout << " 0 books: " << setw(10) << "0 points earned." << endl;
  39. }
  40. else if (booksPurchased == 1)
  41. {
  42. cout << "You have purchased 1 book this month!\n";
  43. cout << " 1 book: " << setw(10) << "5 points earned." << endl;
  44. }
  45. else if (booksPurchased == 2)
  46. {
  47. cout << "You have purchased 2 books this month!\n";
  48. cout << " 2 books: " << setw(10) << "15 points earned." << endl;
  49. }
  50. else if (booksPurchased == 3)
  51. {
  52. cout << "You have purchased 3 books this month!\n";
  53. cout << " 3 books: " << setw(10) << "30 points earned." << endl;
  54. }
  55. else
  56. {
  57. cout << "You have purchased " << booksPurchased << " books this month!\n";
  58. cout << " " << booksPurchased << " books: " << setw(10) << "60 points earned." << endl;
  59. }
  60.  
  61.  
  62.  
  63. return 0;
  64. }
Success #stdin #stdout 0s 5440KB
stdin
Standard input is empty
stdout
How many books did you purchase this month?: 

You have purchased 32767 books this month!
   32767 books:     60 points earned.