TASK 3: Military time operates on a 24-hour clock that uses the range 0 - 23 to represent the hours in a 24 hour period. Midnight (12am) is 0 hours, 1:00 a.m. is 1 hour, 2:00 a.m. is 2 hours, …, noon is 12 hours, 1pm is 13 hours, all the way to 11:00 p.m. being 23 hours. The class Time is a data type (see lecture notes) that represents a military time value consisting of hours, minutes, and seconds (see the data members defined in the class). For example, if these data members are set to hours = 13, minutes = 35, and seconds = 45, this military time represents 1:35pm and 45 seconds. The code for the member functions setHours, setMinutes, setSeconds, getHours, getMinutes, and getSeconds has been provided for you. Do NOT modify this code.

TASK 3a: Write code for the member function toString in the class Time by replacing /* INSERT YOUR CODE */ with your solution. This member function returns a string with the format "HH:MM:SS" that contains the hours, minutes, and seconds stored in an object, i.e. an instance of the class Time. To ensure that the values are expressed in this two digit format, call the function in TASK 3b, which converts a number to a string containing two digit characters. You can test the toString function by running the following code in the main function:

  Time time;
  time.setHours(3);
  time.setMinutes(29);
  time.setSeconds(9);
  cout << time.toString() << endl;
Here the toString function returns the string "03:29:09", i.e. 3:29am and 9 seconds.

TASK 3b: Write code for the member function twoDigits in the class Time by replacing /* INSERT YOUR CODE */ with your solution. This function converts an integer to a string with length two. Use the C++ to_string function to convert a number to a string. For example, to_string(29) evaluates to the string "29". Your code must ensure that a single digit number will be preceded by a leading zero in the returned string. Here are examples: the function call twoDigits(0) returns "00"; the function call twoDigits(5) returns "05"; the function call twoDigits(25) returns "25." This function is called by the toString function in class Time (see TASK 3a).

TASK 4: Write code for the accessor and mutator member functions in the class Order by replacing /* INSERT YOUR CODE */ with your solution.

TASK 4a: Write code in the member function display in the class Order by replacing /* INSERT YOUR CODE */ with your solution. This function displays to the screen the data member values (id, price, quantity), the total cost (price x quantity), and the time the order was taken. The price and total cost are displayed with two digits after the decimal place. Call the toString function in the class Time in this function. You can test the display function by running the following code in the main function:

  Time time;                            
  Order order;                                  

  time.setHours(3);                             
  time.setMinutes(29);
  time.setSeconds(9);

  order.setID("aa");
  order.setPrice(5.5);
  order.setQuantity(10);
  order.setTime(time);
  order.display();
Here the display function will display to the screen:

Order aa, $5.50, 10 units, costs $55.00, taken @ 03:29:09

TASK 5: Write code in the main function (remove code you may have inserted into the main to debug TASK 3 and TASK 4) using the algorithm specified in the comments. Write code in the main function to do the following:

i. Define a constant that holds the integer 100, which is the highest possible price for any product that the user is allowed to enter.

ii. Call the function in TASK 6 that reads all orders from the user.

iii. If the user entered at least one order then display all the orders (call the function in TASK 13) and draw a histogram in bar graph form of the prices (call the function in TASK 14) of the entered orders..

iv. You will write nine functions as specified below. Choose descriptive function and variable names.

Place function prototypes BEFORE the main function after the comment // FUNCTION PROTOTYPES GO HERE:

Place function definitions AFTER the main function after the comment // FUNCTION DEFINITIONS GO HERE:

Each function should have a comment (placed above the function definition) that describes the function's task.

Include in this comment a short description of each input parameter.

TASK 6: Write a procedure to read all of the orders from the user. The function has two input parameters: 1) a vector holding values of type class Order (orders entered by the user) and 2) an integer holding the highest price that the user can enter (see TASK 5 part i). Here is the algorithm for the function:

Display the phrase "Enter today's orders:".

Before reading each order from the user display the phrase "Order #?? -", where ?? is an integer starting from one indicating which order the user is currently entering.

Read each order (ID, price, quantity, and time) by calling the functions in TASK 7, TASK 10, TASK 11, and TASK 12. Stop reading orders when the user enters no characters (just clicks the Enter key) when entering the ID. Display the order to the screen before reading the next order.

Add the order into the vector in the input parameter.

You must determine where to use the cin and getline statements. You will encounter an issue with user input when you read a number followed by a string. Read zyBooks chapter 2.15 (Section 2.15 in the section "Mixing cin and getline") to solve this problem.

TASK 7: Write a function to read a valid ID from the user. The function has one input parameter: a vector holding values of type class Order. The function returns a string. A valid ID contains exactly two characters where either character can be a lower case letter or a digit. Repeatedly ask the user again for an ID if an invalid ID is entered and display the phrase "Invalid id, try again." in this case. Call the function in TASK 8 to determine whether a character is a lower case letter or a digit Call the function in TASK 9 to determine if an ID has already been entered by the user. I.e., we don't allow duplicate IDs in the list of orders.

TASK 8: Write a function that determines whether a character is a lower case letter or a digit. The function has one input parameter: a character (not a string). The function returns a boolean value where true indicates that the character in the input parameter is either a lower case letter or a digit. Otherwise it returns false.

TASK 9: Write a function that determines whether an ID is already being used in a previous order. The function has two input parameters: a vector holding values of type class Order and 2) a string holding an ID. The function returns a boolean value where true indicates that the ID specified in the input parameter is already used in an order in the input vector. Otherwise it returns false.

TASK 10: Write a function that reads a price from the user. The function has one input parameter: a double type of value holding the highest price the user is allowed to enter. The function returns a double. Prompt the user with "Price: " and repeatedly ask the user again if an invalid price is entered and display the phrase "Invalid price, try again." in this case. A valid price is a positive number (remember zero is not a positive number) that does not exceed the input parameter value.

TASK 11: Write a function that reads a quantity from the user. The function has no input parameters. The function returns an integer. Prompt the user with "Quantity: " and repeatedly ask the user again if an invalid price is entered and display the phrase "Invalid quantity, try again." in this case. A valid quantity is a positive number (remember zero is not a positive number).

TASK 12: Write a function that reads a single military time value (hours, minutes, and seconds) from the user. The function has no parameters. The function returns an instance (object) of the class Time containing the military time values entered by the user. Prompt the user with the phrase "Time (hrs, min, sec): " and read in the hours, minutes, and seconds. The hours must be an integer in the range 0 - 23, the minutes must be an integers in the range 0 - 59, and the seconds must be an integer in the range 0 - 59. Repeatedly ask the user again if the entered values violate any of these range restrictions and display the phrase "Invalid time, try again." in this case. Use the mutator member functions of the class Time to store these value into an object.

TASK 13: Write a procedure that displays all of the orders. The function has one input parameter: a vector holding values of type class Order. The procedure displays the phrase "Orders:" followed by each order, one per line. Avoid writing redundant code by calling a member function in the class Order.

TASK 14: Write a procedure that displays a bar graph containing prices from a list of order. The procedure has two input parameters: 1) a vector holding values of type class Order and 2) an integer holding the highest possible price. The procedure displays the phrase "Price Histogram: " followed by the bar graph, which displays rows labeled with prices in increments of 20 dollars up to the highest possible dollars. For example, if the second input parameter holds 100, then the bar graph will display five rows with the prices 20, 40, 60, 80, and 100. Each of these prices represents a price range that includes that price. Thus in the same example, the price 20 represents the prices in the range (0 - 20], price 40 represents the range (20 - 40], the price 60 represents the range (40 - 60], the price 80 represents the range (60 - 80], and the price 100 represents the range (80 - 100]. As another example, if the second input parameter to this procedure holds 200, then the bar graph will display 10 rows with the prices 20, 40, 60, 80, 100, 120, 140, 160, and 200. Each row will display a count of how many prices in the list of orders (first input parameter) contain a price in the price range indicated by that row. The count is displayed as sequence of dollar sign characters, $, whose number matches the count.

Be sure that there is a comment documenting each variable.

Be sure that your if statements, for and while loops and blocks are properly indented.

Test your solution.