New, Improved Restaurant Program

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to previous page   go to home page   hear noise   go to next page

Answer:

  • The projects failed because their logic was bad.

Of course.

New, Improved Restaurant Program

Let us practice programming logic a little. Modify the program so the user enters cost of the meal and the percentage for the tip. Then the program calculates and prints the total cost.

This time, there are no blanks to fill. Your job is to figure out how to change the program by inserting the following statements and parts of statements (not given in order). Do this by copying and pasting.

basicCost*tipPercent

System.out.print("Enter the tip percentage: ");

double tipPercent;

tipPercent = scan.nextDouble();

If you want, once you are done, you can copy and paste the program into your editor and save to a file which you can then compile and run.

QUESTION 10:

Copy and Paste (control-C and control-V). Hint: you can replace part of the text by highlighting it and then pasting. What you have previously copied will replace the highlighted part.