Question

Write a program that determines which of a company's eight divisions (North, South, East, West, Northeast,...

Write a program that determines which of a company's eight divisions (North, South, East, West, Northeast, Southeast, Northwest, Southwest) had the greatest sales for a quarter. It should include the following two functions which are called only by main.

double getSales() - it is passed the name of a division. It asks the user for a division's quarterly sales figure, validates the input then returns it. It should be called once for each division. Negative dollar amounts are invalid.

void findHighest() - it is passed the eight sales amounts. It then determines which is the largest and prints the name of the high grossing division along with it's sales figure.

Do not accept dollar amounts less than 0

Do not use arrays

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>
#include <iomanip>
#include <cstdlib>
double getSales();
void findHighest(double, double, double, double);
int main()
{
   double Northeast, Southeast, Northwest, Southwest;

   std::cout << "Enter the quarterly sales for Northeast Division: " << std::endl;
   Northeast = getSales();
   std::cout << "Enter the quarterly sales for Southeast Division: " << std::endl;
   Southeast = getSales();
   std::cout << "Enter the quarterly sales for Northwest Division: " << std::endl;
   Northwest = getSales();
   std::cout << "Enter the quarterly sales for Southwest Division: " << std::endl;
   Southwest = getSales();
   findHighest(Northeast, Southeast, Northwest, Southwest);
   return 0;
}
double getSales()
{
   double sales;
   std::cin >> sales;
   if(sales < 0)
       {
       std::cout << " Error: Invalid figures please enter above zero" << std::endl;
       exit(0);
       }
   return sales;
}
void findHighest(double Northeast, double Southeast, double Northwest, double Southwest)
{

   if (Northeast > Southeast && Northeast > Northwest)
   {
       if(Northeast > Southwest)
       {
           std::cout << "The Northeast division had the greatest number of sales, $";
           std::cout << Northeast << std::endl;
       }
   }
   if (Southeast > Northeast && Southeast > Northwest)
   {
       if(Southeast > Southwest)
       {
           std::cout << "The Southeast division had the greatest number of sales, $";
           std::cout << Southeast << std::endl;
       }
   }
   if (Northwest > Northeast && Northwest > Southeast)
   {
       if(Northwest > Southwest)
       {
           std::cout << "The Northwest division had the greatest number of sales, $";
           std::cout << Northwest << std::endl;
       }
   }
   if (Southwest > Northeast && Southwest > Southeast)
   {
       if(Southwest > Northwest)
       {
           std::cout << "The Southwest divsion had the greatest number of sales, $";
           std::cout << Southwest << std::endl;
       }
   }
}

-----------------------------------------------------------------------


Sample OutPut


Enter the quarterly sales for Northeast Division:
5000
Enter the quarterly sales for Southeast Division:
9000
Enter the quarterly sales for Northwest Division:
6000
Enter the quarterly sales for Southwest Division:
1000
The Southeast division had the greatest number of sales, $9000

Add a comment
Know the answer?
Add Answer to:
Write a program that determines which of a company's eight divisions (North, South, East, West, Northeast,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Help. Write a C++ program that determines which of a company's four divisions (North, South, East,...

    Help. Write a C++ program that determines which of a company's four divisions (North, South, East, West) has the greatest sales for the quarter. It should include three functions at a minimum: float getSales() is passed the name of a division. It asks the user for a division's quarterly sales figure, calls a validate() function that will validate the input, and then returns the value back to main(). This function should be called once for each division. void validate() is...

  • C++ Write a program that determines which of the 6 states had the most traffic tickets...

    C++ Write a program that determines which of the 6 states had the most traffic tickets last year. The 6 states are California, Georgia, Alabama, Illinois, Michigan, and Florida. The program should have the following 2 functions, which are called by main. Int getNumTickets () is passed the name of the state. It asks the user for the number of traffic tickets reported during last year, validates the input and then returns it. It should be called once for each...

  • c plus plus determines which of 5 geographic regions within a major city north south east...

    c plus plus determines which of 5 geographic regions within a major city north south east west and central had the fewest reported traffic accidents last year it should have the following function which are called by main int get NumAccidents is passed the name of a region it asks the user for the number of traffic accidents reported in that region during the last year validates the input then returns it. it should be called once for each city...

  • guys need help please im super lost anyone save me do programming exercise top_div_array.cpp: Winning Division...

    guys need help please im super lost anyone save me do programming exercise top_div_array.cpp: Winning Division app (top_div.cpp) revisited to use arrays This is the same program done last week but using and passing arrays instead of individual variables. Start with the following file / cODE BELOW: // Name: top_div_array.cpp // Description: // This app inputs sales for four regional division and displays the highest. // To accomplish this, use two arrays of equal length - one for sales and...

  • The XYZ Company needs you to write a program that will allow them to enter the...

    The XYZ Company needs you to write a program that will allow them to enter the weekly sales for a salesperson and then the program will calculate things such as most sales (and what day on which they happened), least sales (and day on which they happened), total sales, and daily average. The program will need to do the following: • Validate the user input to ensure that it is not less than 0.0 (0.0 will be acceptable if there...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT