Public class ConversionProgram {
public void start() {
String userChoice = askConversionCategory();
while (userChoice.equals("1") || userChoice.equals("2") || Page 2 of 12
userChoice.equals("3") || userChoice.equals("4") ||
userChoice.equals("5") || userChoice.equals("6")) {
processConversionRequest(userChoice);
userChoice = askConversionCategory();
}
System.out.println("Good Bye!");
}
private String askConversionCategory() {
System.out.println();
String prompt = "Select a conversion category, enter \n" +
"\t\"1\" to convert Length, \n" +
"\t\"2\" to convert Temperature, \n" +
"\t\"3\" to convert Initials, \n" +
"\t\"4\" to convert Date, \n" +
"\t\"5\" to convert Time, \n" +
"\t\"6\" to convert Pig Latin, and\n" +
"\tany other key to quit: ";
String category = acquireInput(prompt);
return category;
}
private void processConversionRequest(String userChoice) {
if (userChoice.equals("1")) {
convertLength();
} else if (userChoice.equals("2")) {
convertTemperature();
} else if (userChoice.equals("3")) {
convertInitials();
} else if (userChoice.equals("4")) {
convertDate();
} else if (userChoice.equals("5")) {
convertTime();
} else if (userChoice.equals("6")) {
convertPigLatin();
}
}
private void convertLength(){
}
private void convertTemperature(){
}
private void convertInitials(){
}
private void convertDate(){
}
private void convertTime(){
}
private void convertPigLatin(){
}
private String acquireInput(String prompt){
System.out.print(prompt);
String input = Keyboard.readInput().trim();
return input;
}
}