Question: Write a Java program that allows users to convert temperatures from Celsius to Fahrenheit and Kelvin. The program also evaluates whether the converted Fahrenheit temperature

Write a Java program that allows users to convert temperatures from Celsius to
Fahrenheit and Kelvin. The program also evaluates whether the converted
Fahrenheit temperature indicates a normal body temperature, a fever, or if it's
slightly elevated. Your task is to analyze the provided code, run it, and then
enhance it based on the requirements below.
The user will be given an option to select option 1 or 2 or 3
- If the user selects option 1 then the user will need to enter the Temperature in
Celsius
Convert it to Fahrenheit
Fahrenheit=(9.0/5)* Celsius +32
Then Evaluate the temperature:
-98\deg F to 99\deg F is considered normal.
- Above 100.4\deg F is considered a fever.
- Other values are considered slightly elevated.
- If the user selects option 2 then the user will need to enter the Temperature in
Celsius
Conver to Kelvin
Kelvin = Celsius +273.15
- If the user select option 3
Displays a message thanking the user for their time (as shown on the Sample
Run)
Invalid option. If the user selects any other number, display an error message
(as shown on the Sample Run)
write the java code from this
import java.util.Scanner; // Needed for the Scanner class
/**
* This program demonstrates the if statement
*/
class IfDemo
{
public static void main(String[] args)
{
char choice; // To store the user's choice
int option;
int number;
// Create a Scanner object to read input.
Scanner keyboard = new Scanner(System.in);
//user enter name then separate first name and last name
System.out.println("Enter your name ");
String inputfName=keyboard.next();
System.out.println("your first name is "+inputfName);
String inputLName=keyboard.next();
System.out.println("your last name is "+inputLName);
System.out.print("Enter your options 1,2 or 3:
");
System.out.println("1: For charactors");
System.out.println("2: Even or divisible by 5");
System.out.println("3: Exit");
option=keyboard.nextInt();
if(option==1){
// Ask the user to enter A, B, or C.
System.out.print("Enter A, B, or C: ");
// Read the first character of the string
choice = keyboard.next().charAt(0);
// choice = input.charAt(0); // Get the first char
// Determine which character the user entered.
if(choice=='A'){
System.out.println("You entered A.");
}else if(choice=='B'){
System.out.println("You entered B.");
}else if(choice=='C'){
System.out.println("You entered C.");
}else{
System.out.println("That's not A, B, or C!");
}
}//option=1
else if(option==2){
System.out.print("Enter a number: ");
number = keyboard.nextInt();
if(number%2==0){
System.out.println("number is even");}
else{
System.out.println("number is not even");
}
if(number%5==0){
System.out.println("number is divisible by 5");
}else{
System.out.println("number is not divisable by 5");
}
}//option=2
else if(option==3){
System.out.println("You didn't enter 1 or 2");
System.out.println("Good bye");
}else{
System.out.println("Thank you for your time!");
}
}//main
}//SwitchDemo

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!