Creating enum and functions

How do I create an enum for this?

Write a program that determines which of a company's four divisions (Northeast, Southeast, Northwest, Southwest) had the greatest sales for a quarter. It should include the following:

1. An enum for the divisions.

2. A function called getSales. This function returns a double and is passed the enum of a division. This function asks the user for a division's quarterly sales figure and validates that what the user enters is not less than 0. The function then returns the value the user entered. This function should be called once for each division. The prompt to the user should be: "Please enter the quarterly sales total for the <division> division:".

3. A function called findHighest. This function does not return anything and is passed the four quarterly sales totals and the four division enums. This function determines which sales figure is the largest and prints the name of the division and its sales figure. The output should be: "The highest quarterly sales figure is from the <division> division, with quarterly sales of <sales total for the division>".

4. A function called getDivisionDescription. This function returns the name of the division, for the division enum passed in.
Enums is typically a way for giving numbers names (each name in an enum is given a number, generally starting at 0 and incremented with each one added, unless specified otherwise). Here's how an enum is set up:

 
enum {name1, name2, name3, name4};


Generally, the names in an enum would be in all caps; doesn't have to be, but generally is. And this is what the enum is practically doing:

1
2
3
4
name1 = 0
name2 = 1
name3 = 2
name4 = 3


To give a name a certain value, you do this:

1
2
3
4
5
6
enum {
name1 = 1,
name2 = 9,
name3 = 20,
name4 = 100,
};


These are the basics of enum. More info about enum could be found here: http://www.cplusplus.com/doc/tutorial/other_data_types/

I hope this helps with your assignment.
Last edited on
Topic archived. No new replies allowed.