Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a program that allows the user to create an estimate of the cost to build a table. This will be a menu-driven program that

Create a program that allows the user to create an estimate of the cost to build a table. This will be a menu-driven program that will continue until the user specifically states that they do not want any additional estimates.

This program will need to do the following:

  • The program should display a welcome message. Include your name as the table builder.
  • The program should display a menu of the shapes of the table. The menu should display Rectangular, Square, Circular, and End Program
  • The program must assure that the menu item entered is valid. If an invalid entry is made, the program should display an error message, redisplay the menu and allow for reentry
  • Once the user enters a valid entry for a table
  • If the user selects Rectangular:
    • The program must allow entry of the length and the width. The program must validate the entry (both sides must be > 0).
    • The program will calculate the total area (area = length * width)
  • If the user selects Square:
    • The program must allow entry of only the length. The program must validate the entry (must be > 0).
    • The program will calculate the total area (area = length * length)
  • If the user selects Circular:
    • The program must allow entry of the diameter. The program must validate the entry (must be > 0). NOTE: The program must allow entry of the diameter. It is NOT correct to enter in the radius. In the real world, the radius cannot be accurately measured.
    • The program will calculate the total area (area = PI * radius * radius). NOTE: use the construct Math.PI to get the Java library version of PI
  • Once the area is calculated, the code should ask the user what type of material they want to use:
  • The program displays a menu with two options
  • Option 1 is laminate – the laminate costs $0.125 per square inch
  • Option 2 is oak – oak costs $0.25 per square inch
  • The program must validate the entry of the choice.
    • If the menu entry is invalid, the program must display an error message, redisplay the menu and allow reentry of the option
  • Once a valid option is selected, the program will calculate the cost of the table. The cost is defined as the number of square inches * cost per square inch based on the type of material selected
  • The program then displays the estimate. The display includes:
    • A title
    • The calculated area of the table
    • The type of material for the table
    • The cost of the table
  • The program needs to keep track of the total number of estimates that have been requested and it must keep track of the total cost of all of the estimates
  • Once the output is displayed, the menu redisplays and allows a new estimate to be requested.
  • Once the user selects End Program, the program will display the final estimation report.
    • If the user only asked for one table, the output will display the final total estimate with the table as singular
    • If the user asked for multiple tables, the output will display the number of tables (with tables plural) and the total cost
    • If the user did not request any estimates at all, the program should display a message stating that.
  • Display a final goodbye message and end the program. Remember to close out the Scanner object.

Additional Requirements

  • A Javadoc comment must appear at the top of the source code containing: Your name, course number, and section (001, 002,... for daytime, 050, 051,... for the evening), and a brief description of what the program does.
  • An end-of-line comment must appear after each closing brace describing the block being closed.
  • Proper indentation must be used.
  • The source file and screenshots must be submitted.
  • The files should be uploaded through CANVAS. I will not accept email attachments.
  • The sample output is below.

EXTRA CREDIT

  • For 5 points of extra credit, make sure that there are no hard-coded numbers anywhere in the code
  • All numbers should be declared as public static final values

e Console X OnlineLab2 [Java Application] C:Program FilesJavajre 1.8.0_251binjavaw.exe Welcome to Tables are Us - Your O

  • VIIELAVC pava APPLIUHLITIQyiam i les pavayre i..U_LJI I yavawv.exe pui II, LULU, 10.JU What shape of table do you wish to bui 

O Console 8 OnlineLab2 [Java Application] C:\Program Files\Java\jre1.8.0 251\bin\javaw.exe Welcome to Tables are Us - Your One Stop Table Shop John Smith - Master Table Builder What shape of table do you wish to build? 1. Rectangular 2. Square 3. Circular 4. End Program Enter menu entry: 5 Error - Invalid Entry. Please reenter a valid value What shape of table do you wish to build? 1. Rectangular 2. Square 3. Circular 4. End Program Enter menu entry:

Step by Step Solution

3.37 Rating (144 Votes )

There are 3 Steps involved in it

Step: 1

CODE import javautil public class Table public static void mainString args int tablechoice variable to read choice for shape of table int materialchoice variable to read choice for type of material in... 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

Step: 3

blur-text-image

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

An Introduction to Programming with C++

Authors: Diane Zak

8th edition

978-1285860114

More Books

Students also viewed these Programming questions