Using Borland 4.5
I think I got most the program done but its hard for me to setup functions with returning names and values.
Problems States:
Winning Division:
Write a program that determines which of a company's four divisions (Northeast, Southeast, Northwest, and Southwest) had the greatest sales for a quarter. It should include the following two functions that are called by main.
-double getSales()is passed the name of a division. It ask the user for a division's quarterly sales figure, validates the input then returns it. It should be called once for each division.
-void findHighest() is passed the four sales totals. It determines which is the figure largest and prints the name of the high grossing division, along with its sales figures.
Input Validation: Do not accept dollar amounts less than $0.00
I really don't understand the first function that is underlined.
This is what I have so far.
#include <iostream.h>
#include <iomanip.h>
#include <stdlib.h>
double getSales(double, double, double, double);
void findHighest(double, double, double, double);
int main()
{
double Neast, Seast, Nwest, Swest;
cout << "This program determines which of a company's four divisions had " ;
cout << "greatest sales for a quarter." << endl;
cout << "Northeast Division: " << endl;
Neast = getSales();
cout << "Southeast Division: " << endl;
Seast = getSales();
cout << "Northwest Division: " << endl;
Nwest = getSales();
cout << "Southwest Division: " << endl;
Swest = getSales();
findHighest();
}
double getSales()
{
double sales;
cout << "What is the sales for this division?" << endl;
cin >> sales;
if(sales < 0)
{
cout << " Error: Only enter sale figures above zero" << endl;
exit(0);
}
return sales;
void findHighest(double Neast, double Seast, double Nwest, double Swest)
{
cout << setiosflags(ios::showpoint | ios::fixed);
cout << setprecision(2);
if (Neast > Seast && Neast > Nwest)
{
if(Neast > Swest)
{
cout << "The Northeast division had the greatest number of sales, $";
cout << Neast << endl;
}
}
if (Seast > Neast && Seast > Nwest)
{
if(Seast > Swest)
{
cout << "The Southeast division had the greatest number of sales, $";
cout << Seast << endl;
}
}
if (Nwest > Neast && Nwest > Seast)
{
if(Nwest > Swest)
{
cout << "The Northwest division had the greatest number of sales, $";
cout << Nwest << endl;
}
}
if <Swest > Neast && Swest > Seast)
{
if(Swest > Nwest)
{
cout << "The Southwest divsion had the greatest number of sales, $";
cout << Swest << endl;
}
}
}