8:19 AM .OOOO H20 100% ehacc hacc.edu Input: The temperature in Fahrenheit degre
ID: 3783143 • Letter: 8
Question
8:19 AM .OOOO H20 100% ehacc hacc.edu Input: The temperature in Fahrenheit degrees, provided interactively by the user. The input value will be a real number Output: Display the Fahrenheit input temperature and the corresponding Celsius temperature, also a real number. The results may be displayed on the screen. Provide a simple message to explain the output (ie., one sentence). At least the Java output should be formatted neatly, with one decimal position displayed in the numbers. Sample output: 212-o degrees Fahrenheit 1oo.o degrees Celsius. amming Include at least some documentation in this simple program .Initial comments at the beginning of each file should provide the program name, your name, and a simple statement of what the program does. .Include one other comment somewhere in each program, either in-line or on a separate line. Include a meaningful prompt for the user. To avoid doing data conversions or losing data through integer truncations, use only real numbers in the calculations. A number constant will be treated as a real number if you include a decimal pointand a trailing Formula Submissions: Submit an electronic copy of the of your algorithm fist in the D2Ldropbox. Due date is listed above. Then submit the two source code files in the D2L dropbox. Due date is listed above. Algorithm is worth 6 points. Each program is worth 7 points. Include your initials at the beginning of the name of any program submissionExplanation / Answer
PROGRAM CODE:
TemperatureConvertor.java
package simple;
import java.util.Scanner;
/**
* This program is used for reading a real number from the user which represents the Fahrenheit temperature in degrees.
* This temperature is then converted to Celsius temperature using the formula, C = 5/9(F-32)
* The result is then displayed to the user
* @author your Name
*
*/
public class TemperatureConvertor {
public static void main(String args[])
{
Scanner consoleReader = new Scanner(System.in);
double fahrenheitTemp = 0.0, celsiusTemp = 0.0;
//Prompting the user to enter the fahrenheit temperature
System.out.print("Enter the Fahrenheit temperature(degrees): ");
//Reading the value from the console
fahrenheitTemp = consoleReader.nextDouble();
//calculating celsius temperature
celsiusTemp = (5.0/9.0)*(fahrenheitTemp - 32.0);
System.out.printf("The Celsius temperature is %.1f degrees Celsius", celsiusTemp);
consoleReader.close();
}
}
OUTPUT:
RUN #1
Enter the Fahrenheit temperature(degrees): 32
The Celsius temperature is 0.0 degrees Celsius
RUN #2
Enter the Fahrenheit temperature(degrees): 98.3
The Celsius temperature is 36.8 degrees Celsius
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.