Question: Write a class that contains the following three methods: / * Convert from feet to meters * / public static double footToMeter ( double foot

Write a class that contains the following three methods:
/* Convert from feet to meters */
public static double footToMeter (double foot)
/* Convert from meters to feet */
public static double meterToFoot (double meter)
/* Print conversion result */
public void printConversion(String conversionType, double value)
The formula for the conversion is:
Meter =0.305* foot
Foot =3.279* meter
Instructions:
The printConversion() method should take a string ("footToMeter" or "meterToFoot") to specify
the type of conversion and a value for conversion, then print the result.
For example:
If the input is "footToMeter" and value =10, it should print 10 feet is 3.05 meters.
If the input is "meterToFoot" and value =10, it should print 10 meters is 32.79 feet.
If the input is not "footToMeter" nor "meterToFoot", it should print Invalid conversion type. Please
use footToMeter or meterToFoot.
Test your code using the following lines in your main method:
yourClassVariable.printConversion("footToMeter",10);
yourClassVariable.printConversion("meterToFoot",10);
yourClassVariable.printConversion("aWrongEntry",10);
Expected output:
10.0 feet is 3.050 meters.
10.0 meters is 32.790 feet.
Invalid conversion type. Please use footToMeter or meterToFoot.

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 Programming Questions!