Need this done in java Write a complete main() method that creates a menu system
ID: 3757683 • Letter: N
Question
Need this done in java
Write a complete main() method that creates a menu system that lets the user convert between Fahrenheit, Celsius, and Kelvin temperatures. Assume each conversion method will be implemented as a separate void() method. You do not need to write the conversion methods; you just need to give them appropriate names so you can code them call in main().
The menu dialog follows. Reverse engineer and code it. If the menu choice is valid (A-F), call the appropriate conversion by invoking your named conversion method. Then, return and redisplay the menu for another "go."
If they choose Q quit the menu system, display Goodbye and end the program. If it is invalid (any other input besides A-F or Q), show an error message and present the menu again.
Choose conversion:
A: F to C
B: F to K
C: C to F
D: C to K
E: K to F
F: K to C
Q: Quit
Choice: M
Error: Invalid choice; try again
Choose conversion:
A: F to C
B: F to K
C: C to F
D: C to K
E: K to F
F: K to C
Q: Quit
Explanation / Answer
As you said not to write conversion methods,,,i didnt included in code as per your request
import java.util.Scanner;
public class HelloWorld{
public static void main(String []args){
Scanner sc = new Scanner(System.in);
while(true){
//menu displaying
System.out.println("Choose conversion: ");
System.out.println("A: F to C B: F to K C: C to F D: C to K E: K to F F: K to C Q: Quit");
System.out.println("Choice: ");
//reading choice from user
Scanner choice = sc.nextLine();
if(choice.equals("A"){
convertFtoC();
}
else if(choice.equals("B"){
convertFtoK();
}
else if(choice.equals("C"){
convertCtoKF();
}
else if(choice.equals("D"){
convertCtoK();
}
else if(choice.equals("E"){
convertKtoF();
}
else if(choice.equals("F"){
convertKtoC();
}
else if(choice.equals("Q"){ //if we want to quit, then quit
System.out.println("Good Bye!!");
break;
}
else{//if wrong entry entered
System.out.println("Error: Invalid choice; try again");
}
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.