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

  1. In Eclipse, create a new Java Project named "UnitConverter"
  2. In the UnitConverter project, create a package named "main"
  3. 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:

  1. Create an int variable named menuSelection
  2. Inside a while loop, with the condition menuSelection != /*last menu option */
    1. Using System.out.println(), print a menu with numbered options. For example:
      1. Please select an option: 1. Cups to Teaspoons 2. Miles to Kilometers 3. US Gallons to Imperial Gallons 4. Quit 
    2. Use a Scanner object to collect the user's menuSelection
    3. switch on the selection to collect the user's quanity of the first unit, convert to the second unit, and print the output.

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!