Problem Set 2: Fahrenheit
Web-CAT: Submit Java programs to this automated grading platform.
Background
- Due Date: Monday, September 16, 2019
- Total Points: 10
- In this problem set, you must write a
Javaprogram that performs a simple temperature conversion.
Code Distribution
| Description | File Size | File Name |
|---|---|---|
Java Source Code for Fahrenheit |
4.1KB | pset02.zip |
Contents of pset02.zip:
PSet02SourceCode/
├── Fahrenheit.class
├── Fahrenheit.ctxt
├── Fahrenheit.java
├── FahrenheitJUnitTest.class
├── FahrenheitJUnitTest.ctxt
├── FahrenheitJUnitTest.java
├── package.bluej
└── README.TXT
Specification
- Write a
Javaprogram in the fileFahrenheit.javathat converts a temperature from celsius to fahrenheit. The formula for this conversion is as follows: Take the temperature in celsius, multiply it by 9, divide the result by 5, and add 32. The equation can be expressed as:
\mbox{fahrenheit} = \frac{\mbox{celsius} \times 9}{5} + 32
-
You will write your solution in a function called
calculateFahrenheit(double celsius), right below the place where it says:YOUR CODE HERE. -
When the function call
calculateFahrenheit(100)is executed, the output of the program should be:212.0
Hints
- Recall that
Javaperforms integer division. You may have to multiply one of the constants in the equation by1.0to obtain the correct answer.
Testing
- Click on the Run Tests button to execute the
JUnittest bench.JUnitindicates a successful test with a green bar, and an unsuccessful test with a red bar.
Submission
- Upload the file
Fahrenheit.javato the Web-CAT automated grading platform.