Question: Design a Java program named KitchenConverter which converts cups to tablespoons using the formula 1 cup = 16 tablespoons. Your program must prompt the user
Design a Java program named "KitchenConverter" which converts cups to tablespoons using the formula 1 cup = 16 tablespoons.
- Your program must prompt the user for the number of cups and display both the input value and calculated result.
- Your program must accept fractional values for the number of cups.
- Your program must declare two variables: one to store the user's input and one to store the calculated result.
- Your program must use named constants for any numeric literals (in other words, don't hardcode values into any formulas).
- Use the System.out.printf method (or System.out.format method) as you did in the ungraded practice exercise to format floating point values with 2 significant places after the decimal point (using "%.2f" as the format specifier will format a variable's display with 2 significant places). Here's the statement you'll want to use (but you'll need to change the variable names shown here to your own variable names):
System.out.printf("%.2f cups is %.2f tablespoons ", cups, tbsp);
Use the Module 1 Ungraded Practice Exercise instructor solution posted above for examples of how to code this assignment (note that you will need to submit a solution to that exercise in order to view the instructor solution).
Test your program using the input shown below. Use the expected output included below for guidelines on what your output should look like.
What you don't need (and should not include) in this assignment:
- Loops for repeated input
- Input validation
Even if you know how, or can figure these out, please don't include them; we will cover these topics in an upcoming unit. You can code them separately and e-mail your code to me if you want me to take a look.
Attach and submit your .java file to this assignment. Read the Programming Assignment Rubric in the Course Content top-level folder for information on how this assignment will be graded. Be sure to include an ID header at the top of your file. Do not attach program output, project files, .class files, or any files other than your .java source file.
If you get stuck, e-mail me for help! david.singletary@fscj.edu
Program Input:
Run your program four times using the following input (one input value for each program run): 6 2.5 0.75 0.6
Expected Output (user input shown in red): This program converts cups to tablespoons Please enter the number of cups: 6 6.00 cups is 96.00 tablespoons
This program converts cups to tablespoons. Please enter the number of cups: 2.5 2.50 cups is 40.00 tablespoons
This program converts cups to tablespoons. Please enter the number of cups: 0.75 0.75 cups is 12.00 tablespoons
This program converts cups to tablespoons. Please enter the number of cups: 0.6 0.60 cups is 9.60 tablespoons
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
