Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 or or
If the user selects option then the user will need to enter the Temperature in
Celsius
Convert it to Fahrenheit
Fahrenheit Celsius
Then Evaluate the temperature:
deg F to deg F is considered normal.
Above deg F is considered a fever.
Other values are considered slightly elevated.
If the user selects option then the user will need to enter the Temperature in
Celsius
Conver to Kelvin
Kelvin Celsius
If the user select option
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 mainString args
char choice; To store the user's choice
int option;
int number;
Create a Scanner object to read input.
Scanner keyboard new ScannerSystemin;
user enter name then separate first name and last name
System.out.printlnEnter your name ;
String inputfNamekeyboard.next;
System.out.printlnyour first name is inputfName;
String inputLNamekeyboard.next;
System.out.printlnyour last name is inputLName;
System.out.printEnter your options or :
;
System.out.println: For charactors";
System.out.println: Even or divisible by ;
System.out.println: Exit";
optionkeyboard.nextInt;
ifoption
Ask the user to enter A B or C
System.out.printEnter A B or C: ;
Read the first character of the string
choice keyboard.nextcharAt;
choice input.charAt; Get the first char
Determine which character the user entered.
ifchoiceA
System.out.printlnYou entered A;
else ifchoiceB
System.out.printlnYou entered B;
else ifchoiceC
System.out.printlnYou entered C;
else
System.out.printlnThats not A B or C;
option
else ifoption
System.out.printEnter a number: ;
number keyboard.nextInt;
ifnumber
System.out.printlnnumber is even";
else
System.out.printlnnumber is not even";
ifnumber
System.out.printlnnumber is divisible by ;
else
System.out.printlnnumber is not divisable by ;
option
else ifoption
System.out.printlnYou didn't enter or ;
System.out.printlnGood bye";
else
System.out.printlnThank you for your time!";
main
SwitchDemo
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started