2
answers
2
watching
230
views

Problem: Meal gift card. Your favorite campus restaurant sells meals for $13 each meal. The restaurant requires members to pre-pay any amount of money they wish, and then purchase as many meals accordingly. You are required to write a java program correctly that would ask the user for the amount that they will pay, then display a message indicating how many meals that user will be able to purchase as well as how much funds will remain in the gift card after that. 

Using exactly 1 integer constant, 3 integer variables, and 1 Scanner variable make sure to fulfill the following points:

1. Declare the following constant integer: PRICE and set it to 13.

2. Declare 3 unassigned integer variables amount, meals, balance.

3. Declare 1 Scanner variable that will record keyboard inputs.

4. Prompt the user in the console for the amount that they will pay and assign to amount (use same format and wording as in the sample outputs below). Assume the user will enter an integer value.

5. Assign to meals the result of amount / PRICE.

6. Assign to balance the result of amount % PRICE.

7. Output to the console a blank line followed by the message

With $ you can buy meals and will have a balance of $.

Where ,and are the values stored in the corresponding variables. 

Based on the previous specifications your program should look and behave exactly as displayed in the cases below. Your
program should work for any double values entered by the user, not just the ones in the sample.
Note that ◦ symbol indicates a space and ↵ is a new line character. All words except for user input (in blue) must be exactly as indicated in the sample. Any extra “spaces” and/or “new lines” will be graded a wrong answer.

Note 1: You are to expect a perfect user who always enters integer numbers., do not verify the validity of user input.
Note 2: The use of libraries other than java.util.Scanner is prohibited. Your program must work for any integer values entered, not just the ones in the samples above.
Note 3: Final thought, remember that your solution is space-sensitive and fulfill the above instructions carefully and
precisely.

For unlimited access to Homework Help, a Homework+ subscription is required.

Unlock all answers

Get 1 free homework help answer.
Already have an account? Log in
Avatar image
Read by 1 person
Already have an account? Log in

Related questions

Related Documents

Weekly leaderboard

Start filling in the gaps now
Log in