Colorado State University

Recitation R3 - Java: Control Loops and Restaurant Receipts
Summer 2016

CS160: Foundations in Programming


In this recitation we will:

Interpretation Section

Practice Problems

Getting Started: Restaurant Reciepts

Specifications: Finishing the Program

  1. Instantiate and initialize a Scanner object.

  2. Prompt the user for the name of the restaurant.
  3. Read in the user's input to the variable restaurantName.
  4. Prompt the user for the name of the server.
  5. Store the value in the variable serverName.
  6. Prompt the user for the cost of the bill.
  7. Store the value in the variable subtotal.

  8. Write a method to calculate the tax on the bill based on the subtotal and taxRate.
        public static double computeTax(double amount, double rate) 

  9. Call the method and store the result in the variable tax.

  10. Calculate the total bill by adding the subtotal and tax together. Store the total bill in the variable total.

  11. Write a method to calculate the suggested tip, based on the total and the tip rate.
  12.     public static double computeTip(double amount, double rate) 

  13. Using the calculated values you stored in variables, print a receipt to the console.

Sample Output

Make sure you copy exactly the format of the receipt as seen here.
Park Sushi
Server: JULIE
Subtotal: $56.23
Tax: $2.81
Total: $59.04

Suggested tips:
10%: $5.90
15%: $8.86
20%: $11.81

Thank you!

Additional Tips and Tricks

Note the following details: Some tips:

Once you have completed the interpretation exercise, Hackerrank activities, and submitted to Checkin you are finished.

© 2016 CS160 Colorado State University. All Rights Reserved.