Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

If you can include the Bonus it would be appreciated. Please code in Java. Conversion Program Write a program that allows the user to convert

If you can include the Bonus it would be appreciated. Please code in Java.

Conversion Program

Write a program that allows the user to convert a given volume to different units and print the converted value to the console. The user can convert gallons to liters or convert liters to gallons. There are 3.785 liters in one gallon.

Your program should prompt the user (customer) to enter the following information:

Type of conversion to calculate

Volume to convert

The program then outputs the following information:

Converted volume

Menu to be displayed for the user:

CONVERSION TOOL 1. Gallons to liters 2. Liters to gallons 

Note: To indicate the type of conversion, the user will enter the number of the conversion, NOT the type of conversion. For example, if the user wants to convert gallons to liters, he/she wouldtype 1 (not Gallons to liters). Please refer to the Sample Output file for full details of what the program should look like when it runs.

Your program MUST contain the following three user-defined methods, in addition to themain method: 1. Convert gallons to liters

2. Convert liters to gallons

3. Print converted volume

When you write each of your methods, be sure to think about the following:

What information does the main method need to send to this method in order for it to work properly? For example, in order to calculate the total liters, what information does the method need from main?

What information does main expect to receive, if any, after this method executes? For example, when calculating the total liters, what information does main expect to receive from the method?

1

This assignment MUST be created individually. You must turn in your OWN source code and Java bytecode executable file.

Instructions

Compile and execute your program to ensure that it works correctly.

Be sure to run your final program using the sample data included in the Sample Output

file to ensure your program works properly.

Make sure your output labels match those in the Sample Output file exactly.

Notes

You MUST store any calculations in variables (i.e. do not calculate the conversions directly in your System.out.println statements)

You do NOT need to worry about formatting the decimal places on values you calculate

You must include the three methods specified on the previous page (in addition to main).

You may include additional methods if you want, but you MUST include at least these

three methods (and main).

You may perform the tasks in any order as long as your output follows the order of the

output in the example scenarios contained in the Sample Output file

Extra credit (10 points)

Write two additional methods to allow the user to convert teaspoons to milliliters and milliliters to teaspoons. Modify the method that prints the converted value to print these new conversions. There are 4.9289 milliliters in 1 teaspoon.

Please refer to the Sample Output BONUS file for scenarios that incorporate the new conversion types.

To receive full credit:

o File with your Java source code (.java file) o File with your Java bytecode executable file (.class file) o Refer to the instructions for creating the zip file on Canvas if you do not create

the file with the correct folders and structure, you will lose points

ModulesNetBeans Information > NetBeans -> Where are my files for my hw

You must follow the appropriate Coding Standards listed in the Coding Standards

document under Modules on Canvas. o 40% of your grade on the source code will be based on how well you follow these

standards and how well you comment your source code

SAMPLE PROGRAM OUTPUT

Because there are several different things your program might do depending upon what the user enters, please refer to the examples below to use to test your program. Run your final program one time for each scenario to make sure that you get the expected output.

Be sure to format the output of your program so that it follows what is included in the examples. Remember, in all examples bold items are entered by the user when the program runs (and therefore can change each time the program runs).

Scenario 1: User converts gallons to litersCONVERSION TOOL

 1. Gallons to liters 2. Liters to gallons 

Please select the type of conversion you would like to make: 1Please enter the gallons: 5 The total liters is 18.925

Scenario 2: User converts liters to gallonsCONVERSION TOOL

 1. Gallons to liters 2. Liters to gallons 

Please select the type of conversion you would like to make: 2Please enter the total liters: 10 The total gallons is 2.642008

Scenario 3: Invalid conversion selectionCONVERSION TOOL

 1. Gallons to liters 2. Liters to gallons 

Please select the type of conversion you would like to make: -1Invalid conversion selection. Please run the program again.

SAMPLE PROGRAM OUTPUT - BONUS

Because there are several different things your program might do depending upon what the user

enters, please refer to the examples below to use to test your program. Run your final program one time for each scenario to make sure that you get the expected output.

Be sure to format the output of your program so that it follows what is included in the examples. Remember, in all examples bold items are entered by the user when the program runs (and therefore can change each time the program runs).

Scenario 1: User converts gallons to litersCONVERSION TOOL

 1. Gallons to liters 2. Liters to gallons 3. Teaspoons to milliliters 4. Milliliters to teaspoons 

Please select the type of conversion you would like to make: 1Please enter the gallons: 5 The total liters is 18.925

Scenario 2: User converts liters to gallonsCONVERSION TOOL

 1. Gallons to liters 2. Liters to gallons 3. Teaspoons to milliliters 4. Milliliters to teaspoons 

Please select the type of conversion you would like to make: 2Please enter the total liters: 10 The total gallons is 2.642008

Scenario 3: User converts teaspoons to millilitersCONVERSION TOOL

 1. Gallons to liters 2. Liters to gallons 3. Teaspoons to milliliters 4. Milliliters to teaspoons 

Please select the type of conversion you would like to make: 3Please enter the total teaspoons: 3 The total milliliters is 14.7867

Scenario 4: User converts milliliters to teaspoonsCONVERSION TOOL

 1. Gallons to liters 2. Liters to gallons 3. Teaspoons to milliliters 4. Milliliters to teaspoons 

Please select the type of conversion you would like to make: 4Please enter the total milliliters: 20 The total teaspoons is 4.057700501

1

Scenario 5: Invalid conversion selectionCONVERSION TOOL

 1. Gallons to liters 2. Liters to gallons 3. Teaspoons to milliliters 4. Milliliters to teaspoons 

Please select the type of conversion you would like to make: -1Invalid conversion selection. Please run the program again.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Transactions On Large Scale Data And Knowledge Centered Systems Iv Special Issue On Database Systems For Biomedical Applications Lncs 6990

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Christian Bohm ,Johann Eder ,Claudia Plant

2011th Edition

3642237398, 978-3642237393

More Books

Students also viewed these Databases questions

Question

What is project portfolio management?

Answered: 1 week ago

Question

Describe how language reflects, builds on, and determines context?

Answered: 1 week ago