Starting from:
$28

$19.60

SOLVED Assignment 7: The Restaurant Bill (Part 2 of N)

Objectives

  • Ask the user for the names of three food products and their prices.
  • Add up each of the three meals and their prices.
  • Display the data using the printf method.

Motivation

The restaurant was happy with the bill tool that you wrote for them, but they need some enhancements. Everyone who shows up at the restaurant orders a entrée, a drink, and a dessert. You need to write a program which will prompt for the names of each of the three meals and their prices. You will then prompt for the name of the server. Finally, you will sum the total of the bill, compute the tax (like last time, it's 7%) and then present the low, medium, and high tip suggestions. You are encouraged to edit your assignment 3 since there is so much overlap with this assignment and assignment 3.

Instructions

Name your project FirstnameLastnameAssignment7

Have your program do the following.

  • Make sure that the sales tax is stored as a constant double equal to 7.0 and that the three suggested tip levels (low is 15%, medium is 18%, and high is 20%) are also stored as constant doubles.
  • Greet the user with your name and what this program accomplishes.
    • For example, "Welcome to Dr. Church's Restaurant Bill Tool. Part 2"
  • Prompt the user for the price of the entree.
  • Prompt the user for the price of the drink.
  • Prompt the user for the price of the dessert.
  • Prompt the user for the name of the server.
  • Display back to the user each of these three values using formatted output. See the format requirements below.
  • Compute the total without tax (add the price of the entree, drink, and dessert).
  • Compute the sales tax and display it. Again, see the format requirements below.
  • Display the total with tax (total plus sales tax). See format requirements.
  • Compute and display the low tip suggestion. See format requirements.
  • Compute and display the medium tip suggestion. See format requirements.
  • Compute and display the high tip suggestion. See format requirements.

Format requirements.

Since every numerical value in this assignment is a dollar amount, you should display all floating point numbers with a display width of 6 spaces and rounded to 2 decimal places. Also, make sure all dollar amounts begin with a dollar sign. (See the example below.) See page 167 in the textbook for an example of a number being rounded using 2 decimal places. Each of the leading strings needs to be displayed using 20 spaces and right justified. Rather than space out everything and counting spaces on the screen, use the format code to display a string using 20 spaces.

Documentation

Your source code must include the following documentation:

  • Your name
  • The class (CS 2070) and the section number (on ground is 08, online is W1).
  • The date on which you turned in the assignment.
  • A short description of the software. Usually a sentence or two is sufficient.

Example Run

Welcome to Dr. Church's Restaurant Bill Tool. Part 2
Enter the price of the entree: 8.5
Enter the price of the drink: 1.99
Enter the price of the dessert: 3.5
Enter the name of the server: Hayao Miyazaki
            Entree $ 8.50
              Drink $ 1.99
            Dessert $ 3.50
              Total $ 13.99
                Tax $ 0.98
      Total w/ Tax $ 14.97
            Low Tip $ 2.25
        Medium Tip $ 2.69
          High Tip $ 2.99
      Your server: Hayao Miyazaki

Take special care to make sure that each line is formatted correctly. Even the last line with the server name uses “Your server:” displayed to 20 spaces. You should be using the System.out.printf” method for displaying everything after the initial prompts. (For the initial prompts, I used the regular “System.out.print” method.)

Turning it in.

To turn in your application, find the folder containing your entire project (not the folder with the "java" file), zip it up, and turn it in.