Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this Programming Activity, you will write a program to convert a temperature in Fahrenheit to Celsius. The conversion formula is the following: T c

For this Programming Activity, you will write a program to convert a temperature in Fahrenheit to Celsius. The conversion formula is the following:

  • Tc = 5 / 9 ( Tf 32 )

where Tc is the temperature in Celsius and Tf is the temperature in Fahrenheit, and 32 is the freezing point of water.

Locate the TemperatureConversion.java source file found in this chapters Programming Activity 2 folder in the supplied code files. Copy the file to your computer. The source code is shown in Example 2.11.

EXAMPLE 2.11 TemperatureConversion.java

 1 /* Temperature Conversion 2 Anderson, Franceschi 3 */ 4 5 public class TemperatureConversion 6 { 7 public static void main( String [ ] args ) 8 { 9 //***** 1. declare any constants here 10 11 12 //***** 2. declare the temperature in Fahrenheit as an int 13 14 15 //***** 3. calculate equivalent Celsius temperature 16 17 18 //***** 4. output the temperature in Celsius 19 20 21 //***** 5. convert Celsius temperature back to Fahrenheit 22 23 24 //***** 6. output Fahrenheit temperature to check correctness 25 26 27 } 28 }

Open the TemperatureConversion.java source file. Youll notice that the class already contains a class name and the main method. Your job is to fill in the blanks.

To verify that your code produces the correct output, add code to convert your calculated Celsius temperature back to Fahrenheit and compare that value to the original Fahrenheit temperature. The formula for converting Celsius to Fahrenheit is:

Tf = 9 / 5 * Tc+ 32

Before writing this program, you need to design a plan of attack. Ask yourself:

  • What data do I need to define?

  • What calculations should I make?

  • What is the output of the program?

  • How do I select data values so they will provide good test data for my code?

Choose any input value for the Fahrenheit temperature. After you write the program, try changing the original temperature value, recompiling and rerunning the program to verify that the temperature conversion works for multiple input values.

May you put in beginners Java if possible?Thanks

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Visual Basic 6 Databases

Authors: Charles Williams

1st Edition

1861002025, 978-1861002020

More Books

Students also viewed these Databases questions

Question

1 . 7 1 0 - 5 = x ( 0 . 5 + 2 x ) 2

Answered: 1 week ago