1/99
Looks like no tags are added yet.
To map a menu choice to an item name, the program uses:
return (choice == 1) ? "Bread":
(choice == 2) ? "Milk":
(choice == 3) ? "Soap":
"Unknown";Why is a ternary conditional operator used?
Because it selects and returns one string value based on the conditions.
Which information does the user enter when running this program?
A. The item price
B. The output filename
C. The user's age
D. The tax rate
E. The menu choice
F. The calculated total
A, C, E
To format the invoice, the program uses:
A. setw() with a number in parentheses to set column width
B. setw() with a named constant to set column width
C. Tabs to separate the label and amount
D. setprecision() with a number in parentheses
E. setprecision() together with fixed to specify decimal places
F. setprecision() together with fixed to specify significant digits
A, B, C, D, E
What does the following statement do?
double tax = isTaxable(itemChoice) ? (price * TAX_RATE) : 0.0;It calculates 8% tax if the item is taxable; otherwise, it assigns zero.
What happens if the user's age is 59?
double discountAmount =
(age >= SENIOR_AGE) ? -(price * DISCOUNT_RATE) : 0.0;The discount amount is zero.
What is the purpose of this loop?
for (int i = MIN_CHOICE; i <= MAX_CHOICE; i++) {
cout << i << "." << mapChoiceToItem(i) << ":" << endl;
}To display the ten menu options.
Why does the program use this condition?
while (itemChoice < MIN_CHOICE || itemChoice > MAX_CHOICE)To repeat the prompt while the choice is outside the valid range.
Which line calls the function that formats and prints the tax amount?
A. void printInvoiceLine(string label, double amount);
B. printInvoiceLine("Tax:", tax);
C. double tax = isTaxable(itemChoice) ? (price * TAX_RATE) : 0.0;
D. void printInvoiceLine(string label, double amount)
printInvoiceLine("Tax:", tax);