objective to learn the use of comments and basic


Objective: To learn the use of comments, and basic math operators.

Create a new folder called 'assign21' under C:\Java\Lesson2. Copy HelloWorld.java from Lesson 1 into it, and rename the file to "Temperature.java". Replace the word "HelloWorld" with "Temperature". Replace the System.out line with instructions to declare variables, and display output as described below:

Write a comment in the code that says "Converting degF to degC".

Use the following formula to compute the temperature in Centigrade using the temperature in Fahrenheit:

degree_Centigrade = ( degree_Fahrenheit - 32 ) X 5/9

Display the temperatures in both Centrigrade and Fahrenheit with appropriate labels, using the + operator to concatenate the labels with the variables, each variable on a separate line. For example, the display may look like:

Temperature in Fahrenheit = 75.0

Temperature in Centigrade = 23.88888889

Write another comment in the code that says "Converting degC back to degF". On the next line, declare a new 'double' type variable called 'degFVerify' and then in the next line after that, using the degC computed above, back calculate the temperature in Fahrenheit and assign it to 'degFVerify', using the formula:
degree_Fahrenheit = (degree_Centigrade X 9/5) + 32
Verify that you get back the value of 75.0.

Display another message concatenating a label with the value of 'degFVerify', so that the message may look like:
Temperature in Fahrenheit (Verification) = 75.0
The output session may look like this:
C:\Java\Lesson2\assign21>javac Temperature.java
C:\Java\Lesson2\assign21>java Temperature
Temperature in Fahrenheit = 75.0
Temperature in Centigrade = 23.88888888888889
Temperature in Fahrenheit (Verification) = 75.0

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: objective to learn the use of comments and basic
Reference No:- TGS0484573

Expected delivery within 24 Hours