Question: write a Java program that asks the user for a temperature (in either degrees Celsius or degrees Fahrenheit). If the user entered Celsius, you will

write a Java program that asks the user for a temperature (in either degrees Celsius or degrees Fahrenheit). If the user entered Celsius, you will convert the temperature to Fahrenheit. If they entered Fahrenheit, you will convert the temperature to Celsius. Here is how to convert between temperature systems (be sure to not use integer division in Java so you can keep the decimal of something like 5/9): F = (9/5)*C + 32 C = (5/9)*(F-3This program should contain a single class (called Proj2) with a main method. Your program should compile and run in BlueJ. Here are some additional requirements:

-Your program should work correctly with either upper- or lower-case letters (C/c/F/f)

-You should print an error if the user enters a character other than C/c/F/f

- You should round temperatures to the nearest two decimal places

write a Java program that asks the user for a temperature (in

. You should round temperatures to the nearest two decimal places Here is an example of how to round to two decimal places: //Do this at the very top of the file import java.text.* //Do this once at the beginning of main Decimal Format df = new DecimalFormat("#0.00"); //Suppose you want to print val rounded to the nearest two decimal places double val = 3.278514; System.out.println(df.format(val)); Here is how to get a single character from user input: //Do this at the very top of the file import java.util.* //Do this once at the beginning of main Scanner s -new Scanner(System.in); //This prompts the user for a single character and reads it into letter System.out.print("Enter letter:" char 1etter = (S.nextLine()).charAt(0)

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!