Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

Write a Java Program to display you the following options Please Enter 1 For Coffee 2For Tea 3..For Chocolate When you enter option 1, It

Write a Java Program to display you the following options

Please Enter

1 For Coffee

2For Tea

3..For Chocolate

When you enter option 1, It should display the following message

You choose for Coffee..Price: SAR 5

Please pay the money

When you pay the money there are three cases

If the price of the item is SAR 5

1. If you pay more than SAR 5 it should display

Please take your item and your change is.15

(The change amount: Example If the price for the item is SAR 5 and you pay SAR 20,it will give you change SAR 15 .If you pay SAR 10 it will give you change SAR 5)

2. If you pay SAR 5 it should display

Please take your item and your change is.SAR 0.00

3. If you pay less then SAR 5,it should display a message

You did not pay the sufficient amount. Please Enter the correct amount

When you enter option 2, It should display the following message

You choose for Tea..Price: SAR 4

Please pay the money

When you pay the money there are three cases

If the price of the item is SAR 4

1. If you pay more than SAR 4 it should display

Please take your item and your change is.16

(The change amount: Example If the price for the item is SAR 4 and you pay SAR 20,it will give you change SAR 16 .If you pay SAR 10 it will give you change SAR 6)

2. If you pay SAR 4 it should display

Please take your item and your change is.SAR 0.00

3. If you pay less then SAR 5,it should display a message

You did not pay the sufficient amount. Please ,Enter the correct amount

When you enter option 3, It should display the following message

You choose for Tea..Price: SAR 3

Please pay the money

When you pay the money there are three cases

If the price of the item is SAR 3

1. If you pay more than SAR 3 it should display

Please take your item and your change is.17

(The change amount: Example If the price for the item is SAR 3 and you pay SAR 20,it will give you change SAR 17 .If you pay SAR 10 it will give you change SAR 7)

2. If you pay SAR 3 it should display

Please take your item and your change is.SAR 0.00

3. If you pay less then SAR 5,it should display a message

You did not pay the sufficient amount. Please, Enter the correct amount

Hints:

1.Give the name of your program Assignment#1_yourID

2.Use the Scanner class

3.Use switch statement .You will need three cases.

case1:

case2:

case3:

4.Use if else inside cases.

5.4.Write the program step by step ,Run it, Remove errors and then add other statements

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_2

Step: 3

blur-text-image_3

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

Records And Database Management

Authors: Jeffrey R Stewart Ed D, Judith S Greene, Judith A Hickey

4th Edition

0070614741, 9780070614741

More Books

Students explore these related Databases questions