Question: Need help to explain this methods in Conversion.java Constants for menuID :- Constants for conversion calculations:- Declare variables:- Initialize:- Assign values for menu ft to

Need help to explain this methods in Conversion.java

Constants for menuID :-

Constants for conversion calculations:-

Declare variables:-

Initialize:-

Assign values for menu ft to m:-

Compute conversion based on menuID:-

java code below----

public class Conversion { //Constants for menuID static final int FEET = 1; static final int INCHES = 2; static final int POUNDS = 3; //Constants for conversion calculations static final double METERS_PER_FEET = 0.3048; static final double CENTIMETERS_PER_INCH = 2.54; static final double GRAMS_PER_LB = 453.592; //Declare variables private int menuID; public String mIntputLabel; public String mOutputLabel; public Integer mInputValue; public Double mOutputValue; //Initialize public Conversion() { menuID = FEET; mIntputLabel = "FEET"; mOutputLabel = "METERS"; mInputValue = 0; mOutputValue = 0.0; } //Assign values for menu ft to m public void switch_toFeetMeters() { menuID = FEET; mIntputLabel = "FEET"; mOutputLabel = "METERS"; } //Assign values for menu inch to cent public void switch_toInchesCentimeters() { menuID = INCHES; mIntputLabel = "INCHES"; mOutputLabel = "CENTIMETERS"; } //Assign values for menu lbs to g public void switch_toPoundsGrams() { menuID = POUNDS; mIntputLabel = "POUNDS"; mOutputLabel = "GRAMS"; } //Compute conversion based on menuID public void compute() { switch (menuID) { case FEET: mOutputValue = mInputValue * METERS_PER_FEET; break; case INCHES: mOutputValue = mInputValue * CENTIMETERS_PER_INCH; break; case POUNDS: mOutputValue = mInputValue * GRAMS_PER_LB; break; } } }

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!