fork download
  1. //Andrew Alspaugh CS1A Chapter 7. P. 444. #3.
  2.  
  3. /****************************************************************************
  4.  * Produce Salsa Sales Report
  5.  * __________________________________________________________________________
  6.  * The Purpose of this program is to diplsay how many jars of each type were
  7.  * sold. This program also displays the total number of jars sold. Once the
  8.  * total jars have been calculated, the program finishes by displaying
  9.  * the most and least sold type of salsa
  10.  * ___________________________________________________________________________
  11.  * INPUT
  12.  * TYPE Array Size
  13.  * SALSA[] Array holding Salsa Types (STRING)
  14.  * SALES[] Array holding number of jars sold (INPUT INT)
  15.  *
  16.  *OUTPUT
  17.  * salesTotal Accumulates number of jars sold
  18.  *
  19.  * highest highest number of jars sold
  20.  * highestTYPE name of most jars sold
  21.  *
  22.  * lowest lowest number of jars sold
  23.  * lowestTYPE name of least jars sold
  24.  *
  25.  ****************************************************************************/
  26.  
  27. #include <iostream>
  28. #include <string>
  29. using namespace std;
  30.  
  31. int main()
  32. {
  33. //DATA DICTIONARY
  34.  
  35. //INPUT ARRAY SALSA TYPES
  36. const int TYPE = 5;
  37. string SALSA[TYPE] = {"Mild", "Medium", "Sweet", "Hot", "Zesty" };
  38.  
  39. //INPUT ARRAY NUMBER OF JARS SOLD
  40. int SALES[TYPE];
  41.  
  42. //OUTPUT // ACCUMULATE TOTAL SALES
  43. int salesTotal= 0;
  44.  
  45. //OUTPUT HIGHEST SALES JARS
  46. int highest = 0;
  47.  
  48. //OUTPUT HIGHEST SALES SALSA
  49. int highestTYPE;
  50.  
  51. //OUPTPUT LOWEST SALES JARS
  52. int lowest = 0;
  53.  
  54. //OUTPUT LOWEST SALES SALSA
  55. int lowestTYPE;
  56.  
  57.  
  58. //INPUT
  59. //INPUT NUMBER OF JARS SOLD
  60. for(int count = 0; count < TYPE; count++)
  61. {
  62. cout << "Enter Number Of Jars Sold For " << SALSA[count] << endl;
  63. cin >> SALES[count];
  64.  
  65. while(SALES[count] < 0)
  66. {
  67. cout << "INVALID: NUMBER CANNOT BE NEGATIVE" << endl;
  68. cin >> SALES[count];
  69. }
  70. //ACCUMULATOR
  71. salesTotal += SALES[count];
  72. }
  73.  
  74. //PROCESS
  75.  
  76. highest = SALES[0];
  77. for (int count = 1; count < TYPE; count++)
  78. {
  79. if(SALES[count] > highest)
  80. {
  81. highest = SALES[count];
  82. highestTYPE = count;
  83. }
  84. }
  85.  
  86. lowest = SALES[0];
  87. for (int count = 1; count < TYPE; count++)
  88. {
  89. if(SALES[count] < lowest)
  90. {
  91. lowest = SALES[count];
  92. lowestTYPE = count;
  93. }
  94. }
  95.  
  96.  
  97. //OUTPUT
  98.  
  99. cout << endl << endl;
  100. cout << "SALSA SALES REPORT" << endl << endl;
  101.  
  102. for (int count = 0; count < TYPE; count++)
  103. {
  104. cout << SALSA[count] << "\t\t\t" << SALES[count] << endl;
  105.  
  106. }
  107.  
  108. cout << "Total Sold " << salesTotal << endl;
  109.  
  110. cout << "The Most Sold Type is: " << SALSA[highestTYPE] << endl;
  111.  
  112. cout << "Least Sold Type is: " << SALSA[lowestTYPE] << endl;
  113. return 0;
  114. }
Success #stdin #stdout 0.01s 5324KB
stdin
15
25
1
40
30
stdout
Enter Number Of Jars Sold For Mild
Enter Number Of Jars Sold For Medium
Enter Number Of Jars Sold For Sweet
Enter Number Of Jars Sold For Hot
Enter Number Of Jars Sold For Zesty


SALSA SALES REPORT

Mild			15
Medium			25
Sweet			1
Hot			40
Zesty			30
Total Sold 111
The Most Sold Type is: Hot
Least Sold Type is: Sweet