Java Reference
In-Depth Information
default :
System.out.println("Invalid input.");
}
}
while (choice != 99);
}
public static void showChoices()
{
System.out.println("Enter-");
System.out.println("1: To convert from inches to "
+ "centimeters.");
System.out.println("2: To convert from centimeters to "
+ "inches.");
System.out.println("99: To quit the program.");
}
public static int inchesToCentimeters( int in)
{
return (int) (in * CONVERSION);
}
public static int centToInches( int ct)
{
return (int) (ct / CONVERSION);
}
}
Sample Run: (In this sample run, the user input is shaded.)
Enter--
1: To convert from inches to centimeters.
2: To convert from centimeters to inches.
99: To quit the program.
2
Enter centimeters: 34
34 centimeter(s) =
13 inch(es)
Enter--
1: To convert from inches to centimeters.
2: To convert from centimeters to inches.
99: To quit the program.
1
Enter inches: 45
45 inch(es) = 114 centimeter(s)
Enter--
1: To convert from inches to centimeters.
2: To convert from centimeters to inches.
99: To quit the program.
99
Search WWH ::




Custom Search