fork download
  1. // April 14, 2014
  2. // Antoine Pritchard
  3. // Changes made.
  4.  
  5.  
  6. // Assignment 22 - Add the required calls to the findHighest() and getSales()
  7. // where indicated with //*** comments below.
  8.  
  9. // Chapter 6, Programming Challenge 3: Winning Division
  10. #include <iostream>
  11. #include <iomanip>
  12. #include <string>
  13. using namespace std;
  14.  
  15. // Function prototypes
  16. double getSales(string);
  17. void findHighest(double, double, double, double);
  18.  
  19. int main()
  20. {
  21. double NE, SE, NW, SW;
  22.  
  23. // Determine the division with the highest
  24. // sales figure.
  25.  
  26.  
  27. //*** Call getSales to get the sales figure for each of the four divisions
  28. getSales();
  29.  
  30.  
  31. //*** Call findHighest to find the highest sales figure for the four divisions
  32. findHighest();
  33.  
  34. system("pause");
  35. return 0;
  36. }
  37.  
  38. //*********************************************************
  39. // The getSales function is passed the name of a *
  40. // division. It asks the user for a divisionís quarterly *
  41. // sales figure, validates the input, then returns it. *
  42. //******************************************************* *
  43. double getSales(string divisionName)
  44. {
  45. double sales; // To hold the quarterly sales figure
  46.  
  47. // Get the quarterly sales figure.
  48. cout << "Enter the quarterly sales figure for the "
  49. << divisionName << " division: ";
  50. cin >> sales;
  51.  
  52. // Validate the quarterly sales figure.
  53. while (sales < 0)
  54. {
  55. cout << "The quarterly sales figure must be "
  56. << "a positive dollar amount.\n"
  57. << "Enter the quarterly sales figure for the "
  58. << divisionName << " division: ";
  59. cin >> sales;
  60. }
  61.  
  62. // Return the quarterly sales figure.
  63. return sales;
  64. }
  65.  
  66. //*********************************************************
  67. // The findHighest function is passed the four sales *
  68. // totals. It determines which is the largest and prints *
  69. // the name of the high grossing division, along with its *
  70. // sales figure. *
  71. //*********************************************************
  72. void findHighest(double salesNE, double salesSE,
  73. double salesNW, double salesSW)
  74. {
  75. string divisionName; // To hold the division name
  76. double highestSales; // To hold the highest sales
  77.  
  78. // Determine which sales figure is the largest.
  79. if (salesNE > salesSE &&
  80. salesNE > salesNW &&
  81. salesNE > salesSW)
  82. {
  83. divisionName = "Northeast";
  84. highestSales = salesNE;
  85. }
  86. else if (salesSE > salesNE &&
  87. salesSE > salesNW &&
  88. salesSE > salesSW)
  89. {
  90. divisionName = "Southeast";
  91. highestSales = salesSE;
  92. }
  93. else if (salesNW > salesNE &&
  94. salesNW > salesSE &&
  95. salesNW > salesSW)
  96. {
  97. divisionName = "Northwest";
  98. highestSales = salesNW;
  99. }
  100. else
  101. {
  102. divisionName = "Southwest";
  103. highestSales = salesSW;
  104. }
  105.  
  106. // Display the division with the highest sales.
  107. cout << "\nThe " << divisionName
  108. << " division had the highest sales this quarter."
  109. << "\nThat division's sales were $"
  110. << fixed << showpoint << setprecision(2)
  111. << highestSales << endl << endl;
  112. }
  113.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:28:14: error: too few arguments to function ‘double getSales(std::string)’
     getSales();
              ^
prog.cpp:16:8: note: declared here
 double getSales(string);
        ^
prog.cpp:32:17: error: too few arguments to function ‘void findHighest(double, double, double, double)’
     findHighest();
                 ^
prog.cpp:17:6: note: declared here
 void findHighest(double, double, double, double);
      ^
prog.cpp:34:19: error: ‘system’ was not declared in this scope
     system("pause");
                   ^
prog.cpp:21:12: warning: unused variable ‘NE’ [-Wunused-variable]
     double NE, SE, NW, SW;
            ^
prog.cpp:21:16: warning: unused variable ‘SE’ [-Wunused-variable]
     double NE, SE, NW, SW;
                ^
prog.cpp:21:20: warning: unused variable ‘NW’ [-Wunused-variable]
     double NE, SE, NW, SW;
                    ^
prog.cpp:21:24: warning: unused variable ‘SW’ [-Wunused-variable]
     double NE, SE, NW, SW;
                        ^
stdout
Standard output is empty