Question: In Eclipse, create a new Java Project named UnitConverter In the UnitConverter project, create a package named main Inside the main package, create a class
- In Eclipse, create a new Java Project named "UnitConverter"
- In the UnitConverter project, create a package named "main"
- Inside the main package, create a class named Converter, which has a main(String[]) method.
Inside this main(String[]) method, your code should follow this pattern:
- Create an int variable named menuSelection
- Inside a while loop, with the condition menuSelection != /*last menu option */
- Using System.out.println(), print a menu with numbered options. For example:
-
Please select an option: 1. Cups to Teaspoons 2. Miles to Kilometers 3. US Gallons to Imperial Gallons 4. Quit
-
- Use a Scanner object to collect the user's menuSelection
- switch on the selection to collect the user's quanity of the first unit, convert to the second unit, and print the output.
- Using System.out.println(), print a menu with numbered options. For example:
And that's basically it! But from here, there are a lot of improvements you could make...
- Break the input collection to a seaprate method
-
private static double collectQuantity(String unit1, String unit2) { ... }
-
- Break each unit conversion to a separate method
-
public double convertCelsiusToFarenheit(double qty) { ... }
-
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
