Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

hey want a main menu. After any choice has been processed, the main menu must be

ID: 3620792 • Letter: H

Question

hey want a main menu. After any choice has been processed, the main menu must be shown again.

The menu items are (with each line starting with the key that activates that menu item):
A Purchase apples.
C Purchase cucumbers.
L Purchase lettuce.
T Purchase tomatoes.
! Finalize bill of sale.
* Cancel this bill and reset for new customer.
& Quit program

The purchaser will also pay tax: HST (sales tax) of 13%.

If apples, cucumbers, lettuce, or tomatoes are purchased, then:
For apples and tomatoes, ask the user how many kilograms are to be purchased.
For cucumbers, ask how many are to be purchased.
For lettuce, ask how many heads are to be purchased.
Apples cost $3.59 a kilogram + HST.
Tomatoes cost $2.29 a kilogram + HST.
Lettuce cost $1.49 a head + HST.
Cucumbers cost $1.29 a cucumber + HST.

When a bill finalized, you must output (in the same way as shown in the sample output):
The total number of kilograms of apples purchased, and, the total amount paid for the apples (before taxes).
The total number of cucumbers purchased, and, the total amount paid for the cucumbers (before taxes).
The total number of lettuce heads purchased, and, the total amount paid for the lettuce heads (before taxes).
The total number of kilograms of tomatoes purchased, and, the total amount paid for the tomatoes (before taxes).
The bill subtotal BEFORE taxes are applied.
The total amount of HST for all items in the bill.
The bill total (inclusive of all taxes).

After a bill is finalized, the program must zero out all data and be ready for a new customer, i.e., zero out all variables, reset any other important values, and loop again to display the main menu waiting for user input.

If a request to cancel the current bill is entered in the main menu, then you must:
Ask the user if he/she is sure that he/she wants to cancel the current purchases.
If the user answers "Yes" (no quotes, case insensitive match), then the program must zero out all variables, reset any other important values, and loop again to display the main menu waiting for user input.
If the user answers ANYTHING other than "Yes" then the program must return to the main menu (looping again to show the main menu) as if the user never asked the program to cancel the bill.

If the user requests to "Quit" then the program is to:
If the current bill being tallied has amounts (i.e., anything other than zero), then you must ask, "Are you sure you want to exit while processing a bill?"
If the user answers, "Yes" (case-insensitive), then the program must quit.
Otherwise, the program returns to the main menu.

Requirements

In this assignment, you must:

Use the C type double for all floating-point variables and literals found in the program.

Use the C type unsigned to read in and store all (integer) quantities (e.g., of cucumbers and lettuce).

Use the C type int to store the result from getchar().

Match the output given in the sample output when provided with the same inputs. Different inputs should output the same output except for the correct calculated numbers.

All processing of inputs from the main menu (i.e., the menu) must be done with getchar() and you must use toupper() or tolower() to allow the case-insensitive processing of all menu items.

When you need to input "yes" or "no", you must use scanf() with %s to read in such. Then you must:
Convert all characters in that string to lower case using tolower() inside a for loop over the length of the input string.

Use strcmp() to compare the string to "yes" or "no" as is appropriate.

Use the result of the comparison in an if statement to properly do what is needed.

You are NOT allowed to use goto.

You are allowed to use break or continue within loops.

You must use a switch statement to process the characters input using getchar() (i.e., for the main menu).

If an item is used more than once, you need to ADD more of that item to the previous amount. (See the sample run below.)

If there is zero of any item, then it does NOT appear on the bill-of-sale. (Use an if statement to detect this when outputting the bill-of-sale.) See the sample run below.

In the bill-of-sale, the kg (kilogram) amounts are both output with a width of 6 and 2 decimal places.

In the bill-of-sale, the quantity of cucumbers and lettuce heads are both output using a width of 6. (Remember that these values are UNSIGNED!)

In the bill-of-sale all dollar amounts are output with a width of 7 and 2 decimal places.
Unlike the previous assignments, you have considerable freedom to choose how to do this assignment, except that you must:

only use the C Standard Library, and,
only use C99 language constructs.

I have given some coding suggestions in the Tips section below.

Explanation / Answer

please rate - thanks I think I tested every combination of cancel etc...