Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A local frozen yogurt shop would like you to write a program to help them calculate the cost of their customers yogurt purchases. All yogurt

A local frozen yogurt shop would like you to write a program to help them calculate the cost of their customers yogurt purchases.

All yogurt in the store runs $0.44 per ounce, before toppings. And all purchases will be in whole ounces.

Single servings of yogurt may be purchased in a plastic cup or waffle cone.

o Plastic cups are free. o Waffle cones cost an additional $0.61

Customers may optionally add toppings to their yogurt at $0.53 per topping.

If a customer purchases 10 or more ounces of yogurt, they will get a 5% discount on the entire bill.

Within your program, you must:

Use constants for ALL fixed prices and the discount limit and rate

Use at least one compound arithmetic operator, somewhere in the code

Have a minimum of 4 decisions (however, more may be needed, depending on how the code is implemented).

Test 1

Define the necessary constants at the top of the main method.

Read all the inputs from the user, after creating appropriate variables to hold each answer, as follows:

The number of ounces of yogurt purchased

Whether the customer wants to add toppings o Read the answer from the user

('y'/'Y' for toppings, 'n'/'N' for no toppings, in either upper or lowercase) o If the customer wants toppings, also read the number of toppings to add

(if the customer does not want toppings, do not ask this question)

Whether the customer wants a plastic cup or a waffle cone o Read the answer from the user (1 for plastic cup, 2 for waffle cone).

NOTE: You may assume that the user will enter a valid answer for each question. (see next page for example)

Sample prompts and input

Yogurt Bill Calculator

Enter yogurt weight (whole ounces):

11

Do you want toppings (Y or N)? y

How many toppings?

3

Enter 1 for a plastic cup or 2 for a waffle cone:

2

Test 2

Display 2 blank lines after reading all inputs. Then display an order summary, as follows:

All order details should line up on the right with the last character in position 25.

The container type should be displayed as a String: cone or cup.

If the user did not want toppings, the number of toppings will be 0.

YOGURT ORDER

Weight (oz): 11

Container: cone

Number Toppings: 3

Test 3

Display a blank line. Then calculate and display the bill information, as follows:

YOGURT BILL

Yogurt Cost: 4.84

Cone cost: 0.61

Topping cost: + 1.59

-------

7.04

Only display the cone cost, if the waffle cone is chosen.

Otherwise, if a plastic cup is chosen just display the yogurt and toppings cost lines.

Include an addition operator (plus) on the Topping cost line.

If the number of toppings is 0, display 0.00 for the toppings cost.

NOTE: For formatting purposes, all of the costs will be under 100.00

Tests 4 7

Extend the program to give the customer a discount, if it applies.

(if the discount does not apply, the program should not display anything further).

YOGURT BILL

Yogurt Cost: 4.84

Cone cost: 0.61

Topping cost: + 1.59

-------

7.04

Discount: - 0.35

-------

6.69

If displayed, include a subtraction operator (minus) on the Discount line.

Sample Run 2 (no toppings, no cone, no discount):

Yogurt Bill Calculator

Enter yogurt weight (whole ounces):

8

Do you want toppings (Y or N)?

N

Enter 1 for a plastic cup or 2 for a waffle cone:

1

YOGURT ORDER

Weight (oz): 8

Container: cup

Number Toppings: 0

YOGURT BILL

Yogurt Cost: 3.52

Topping cost: + 0.00

-------

3.52

Any help would be great!

Thanks!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine M. Ricardo

1st Edition

0763733148, 978-0763733148

More Books

Students also viewed these Databases questions

Question

5 Name at least three recruitment methods.

Answered: 1 week ago