//Castulo Jason Quintero CSC5 Chapter 6, P. 369, #3
//
/**************************************************************************
*
* Calculate Winning Division
* ________________________________________________________________________
* This program takes as user input the quartly sales from each
* division and determines which one had the most sales.
*
*
* Computation is based on formula:
* The findHighest function will compare the sales of each
* division and display the store that has the most sales.
* ________________________________________________________________________
* INPUT
* sales : The amount of sales made from a division
*
* OUTPUT
* shop1 : Sales made by the North East
* shop2 : Sales made by the South East
* shop3 : Sales made by the North West
* shop4 : Sales made by the South West
* The output will be which store made the most sales
* followed by the value of the sales made.
*
*************************************************************************/
#include <iostream>
#include <iomanip>
using namespace std;
double getSales(string);
void findHighest(float, float, float, float);
int main()
{
// String variables to hold division names.
string name1 = "North East";
string name2 = "South East";
string name3 = "North West";
string name4 = "South West";
// Variables to hold the value of each division.
float store1;
float store2;
float store3;
float store4;
// Tells the user what will happen
cout << "Enter the sales of each division and the division with the "
<< "most sales will be presented.\n";
// Function that is passed division name, validates, and returns the
// value to the variable associated with the division.
store1 = getSales(name1);
store2 = getSales(name2);
store3 = getSales(name3);
store4 = getSales(name4);
// Function that is passed the values and checks to see which
// division had the most sales.
findHighest(store1, store2, store3, store4);
return 0;
}
// User enters sales of each division and validates it.
double getSales (string storename)
{
float sales;
cout << "Please enter quarterly sales for the " << storename << ": \n";
cin >> sales;
while (sales < 0)
{
cout << "Please enter a value greater than zero: ";
cin >> sales;
}
return sales;
}
// Determines which division has the highest sales.
void findHighest (float shop1, float shop2, float shop3, float shop4)
{
if (shop1 > shop2 && shop1 > shop3 && shop1 > shop4)
{
cout << "Northeast has the most sales! Totaling to $" << shop1;
}
else if (shop2 > shop1 && shop2 > shop3 && shop2 > shop4)
{
cout << "Southeast has the most sales! Totaling to $" << shop2;
}
else if (shop3 > shop1 && shop3 > shop2 && shop3 > shop4)
{
cout << "Northwest has the most sales! Totaling to $" << shop3;
}
else
{
cout << "Southwest has the most sales! Totaling to $" << shop4;
}
}