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
Java
program 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
Java
program in the fileFahrenheit.java
that 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
Java
performs integer division. You may have to multiply one of the constants in the equation by1.0
to obtain the correct answer.
Testing
- Click on the Run Tests button to execute the
JUnit
test bench.JUnit
indicates a successful test with a green bar, and an unsuccessful test with a red bar.
Submission
- Upload the file
Fahrenheit.java
to the Web-CAT automated grading platform.