Question: Do programming exercise top_div.cpp, Winning Division: This program should calculate which division in a company had the greatest sales for a quarter. It should use

Do programming exercise top_div.cpp, Winning Division:

This program should calculate which division in a company had the greatest sales for a quarter. It should use the following functions:

A function should ask the user for and return the quarterly sales figures for the company's Northeast, Southeast, Northwest, and Southwest divisions.

A function should determine which division had the highest sales figures.

A message should be displayed indicating the leading division and its sales figures for the quarter.

Input Validation: Do not accept dollar amounts less than $0.00.

Additional note: The following code for the main function is a required starting point. Create the functions and corresponding prototypes to make this work.

//declare the function prototypes here (before 'main', as explained in the book)

int main()

{

float nE, sE, nW, sW;

nE = input_div( "North East" );

sE = input_div( "South East" );

nW = input_div( "North West" );

sW = input_div( "South West" );

findHighest(nE, sE, nW, sW); //prints the result also

return 0;

} //************ subroutine definitions below *******************

float input_div( string name)

{

Code inputs dollar value for given division and returns it

(Use a while or do/while loop for validation)

}

Note: this function receives the name of the division

('NorthEast', 'SouthEast', etc.) under 'name', which will appear on the prompt

for its sales input.

void findHighest ( receiving 4 'float' types )

{

Code determines the biggest of 4 floats and

prints the result to the screen.

Note: No need to worry about duplicates in this exercise.

Though, there is a 1 point extra credit for implementing duplicate top divisions - make it clear in the header comments that this was done.

}

Pseudocode for findHighest(). Use extra variables

to keep track of the highest value and its corresponding name. Assign these variables the first values of the data and continue checking for and updating the highest data, like this:

highest = nE

name = "North East"

if sE > highest then

highest = sE

name = "South East"

if nW > highest then

highest = nW

name = "North West"

if sW > highest then

highest = sW

name = "South West"

cout "the highest is " name "with" highest

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!