fork download
  1. //OrinTill Qimid CS1A Chapter 4, P. 369, 3
  2. //
  3. /**************************************************************
  4.  * HIGHEST SALES DIVISON
  5.  *
  6.  * ____________________________________________________________
  7.  * This program will find the highest sales among 4 division
  8.  * ____________________________________________________________
  9.  * INPUT
  10.  * sales : the sales of each divison
  11.  * OUTPUT
  12.  * highestDivision : highest sales divison
  13.  * highestSales : highest sales number
  14.  **************************************************************/
  15. #include <iostream>
  16. #include <iomanip>
  17. #include <cmath>
  18. using namespace std;
  19. double getSales(string name);
  20. void findhighest(float northeast, float southeast, float northwest, float southwest);
  21. int main()
  22. {
  23.  
  24.  
  25. double northeast = getSales("Northeast");
  26. double southeast = getSales("Southeast");
  27. double northwest = getSales("Northwest");
  28. double southwest = getSales("Southwest");
  29. findhighest(northeast,southeast,northwest,southwest);
  30. return 0;
  31. }
  32.  
  33. double getSales(string name)
  34. {
  35. double sales;
  36. cout<<"Whats the sales of "<<name<<""<<endl;
  37. cin>>sales;
  38. while (sales<0)
  39. {
  40. cout<<"please eneter a vaild amount of sales"<<endl;
  41. cin>>sales;
  42. }
  43.  
  44. return sales;
  45. }
  46.  
  47. void findhighest(float northeast, float southeast, float northwest, float southwest)
  48. {
  49. string highestDivision;
  50. double highestSales;
  51. if (northeast > southeast && northeast > northwest && northeast > southwest) {
  52. highestDivision = "Northeast";
  53. highestSales = northeast;
  54. }
  55. else if (southeast > northeast && southeast > northwest && southeast > southwest) {
  56. highestDivision = "Southeast";
  57. highestSales = southeast;
  58. }
  59. else if (northwest > northeast && northwest > southeast && northwest > southwest) {
  60. highestDivision = "Northwest";
  61. highestSales = northwest;
  62. }
  63. else {
  64. highestDivision = "Southwest";
  65. highestSales = southwest;
  66. }
  67.  
  68. // Display the division with the highest sales
  69. cout << "The " << highestDivision << " division had the highest sales: $" << highestSales << endl;
  70.  
  71. }
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
Standard output is empty