Question: Download the two source code files of sample code named Temperature.java and TemperatureConverter.java. Those two files make a standalone program which converts Celsius to Fahrenheit
Download the two source code files of sample code named Temperature.java and TemperatureConverter.java.Those two files make a standalone program which converts Celsius to Fahrenheit and Fahrenheit to Celsius.
For this assignment, write a JUnit test case to test two methods in the Temperature class. Test the toCelsius method, and also write a test case to test the toFahrenheit method. You can write both test cases in one class file, which should be a JUnit test file.
Temperature.java
package JunitAssignment;
Chapter
This class can be used to convert from Celsius to Fahrenheit and vice versa.
public class Temperature
Data Members
private double fahrenheit ;
Public Methods:
double toFahrenheit
double toCelsius
void setFahrenheitdouble
void setCelsiusdouble
public double toFahrenheit
return fahrenheit;
public double toFahrenheitdouble tempC
return tempC ;
public double toCelsius
return fahrenheit ;
public double toCelsiusdouble tempF
return tempF ;
public void setFahrenheitdouble degrees
fahrenheit degrees;
public void setCelsiusdouble degrees
fahrenheit degrees ;
TemperatureConverter.java
package JunitAssignment;
Chapter
This class can be used to convert from Celsius to Fahrenheit and vice versa.
public class Temperature
Data Members
private double fahrenheit ;
Public Methods:
double toFahrenheit
double toCelsius
void setFahrenheitdouble
void setCelsiusdouble
public double toFahrenheit
return fahrenheit;
public double toFahrenheitdouble tempC
return tempC ;
public double toCelsius
return fahrenheit ;
public double toCelsiusdouble tempF
return tempF ;
public void setFahrenheitdouble degrees
fahrenheit degrees;
public void setCelsiusdouble degrees
fahrenheit degrees ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
