Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help getting my code to run. public class BusinessClass { // Length public static double inTOcm(double inches) { return 2.54 * inches; }public static double

Help getting my code to run.

public class BusinessClass { // Length public static double inTOcm(double inches) { return 2.54 * inches; }public static double inTOmeter(double inches) { return 0.0254 * inches; }public static double inTOft(double inches) { return 0.083333 * inches; }public static double inTOyd(double inches) { return 0.0277778 * inches; }public static double inTOkm(double inches) { return 0.000254 * inches; }public static double ftTOmeter(double feet) { return 0.3048 * feet; }public static double ftTOyd(double feet) { return 0.0003048 * feet; }public static double ftTOkm(double feet) { return 0.33333 * feet; }public static double ftTOmiles(double feet) { return 0.000189394 * feet; }public static double ydTOmeter(double yard) { return 0.914 * yard; }public static double ydTOft(double yard) { return 3.0 * yard; }public static double ydTOkm(double yard) { return 0.00091444 * yard; }public static double ydTOmile(double yard) { return 0.000568182 * yard;

}

}

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

public class MeasuementClassCalculationsTest { public static void main(String[] args) { // Scanner object for keyboard input Scanner keyboardInput = new Scanner(System.in); // Prompt the user to select an option System.out.println(" Type an option to perform the operation " + " Option 1: Calculate inches " + " Option 2: Calculate feet " + " Option 3: Calculate yards " + " Option 4: End the Program "); optionSelected = keyboardInput.nextInt(); keyboardInput.nextLine(); //Consume enter key while (optionSelected != 4) { switch(optionSelected) { case 1: Calculate cal=new Calculate(inches); System.out.println(" Ounces: "+cal.inTOcm()); System.out.println(" Kilograms: "+cal.inTOmeter()); System.out.println(" Ounces: "+cal.inTOft()); System.out.println(" Ounces: "+cal.inTOyd()); System.out.println(" Ounces: "+cal.inTOkm()); System.out.print(" "); break; case 2: Calculate cal=new Calculate(feet); System.out.println(" Ounces: "+cal.ftTOmeter()); System.out.println(" Kilograms: "+cal.ftTOyd()); System.out.println(" Ounces: "+cal.ftTOkm()); System.out.println(" Ounces: "+cal.ftTOmiles()); System.out.print(" "); break; case 3: Calculate cal=new Calculate(yard) System.out.println(" Ounces: "+cal.ydTOmeter()); System.out.println(" Kilograms: "+cal.ydTOft()); System.out.println(" Ounces: "+cal.inTOkm()); System.out.println(" Ounces: "+cal.inTOmile()); System.out.print(" "); break; case 4: break; default: System.out.println("Enter a number from 1 to 4 only "); } // End of the switch statement // Prompt the user to select an option System.out.println(" Type an option to perform the operation " + " Option 1: Calculate inches " + " Option 2: Calculate feet " + " Option 3: Calculate yards " + " Option 4: End the Program "); optionSelected = keyboardInput.nextInt(); keyboardInput.nextLine(); } } }

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

More Books

Students also viewed these Databases questions

Question

Compose the six common types of social business messages.

Answered: 1 week ago

Question

Describe positive and neutral messages.

Answered: 1 week ago