I have to create a temperature conversion project using a method and driver class...... i did it b4 put only as one file , i started the driver class but when i compile i get a couple errors; the errors i get are:
Degree.java:30: illegal start of expression
public double fahrenheitTemp()
^
Degree.java:24: Degree(float) is already defined in Degree
public Degree(float degree)
^
Degree.java:55: unexpected type
required: variable
found : value
'F' = fahrenheitTemp;
^
Degree.java:56: unexpected type
required: variable
found : value
'C' = celsiusTemp;
^
here is what my constructor method looks like
public class Degree
{
float degree;
double temp;
double fahrenheitTemp;
double celsiusTemp;
char scale;
public Degree(float degree)
{
temp = degree;
scale = 'C';
}
public Degree(float degree)
{
temp = degree;
scale = 'F';
public double fahrenheitTemp()
{
fahrenheitTemp = celsiusTemp * 5/9-32;
return fahrenheitTemp;
}
public double celsiusTemp()
{
celsiusTemp = fahrenheitTemp * 9/5+32;
return celsiusTemp;
}
public String toString()
{
return "Fahrenheit Temperature: " + fahrenheitTemp;
return "Celsius Temperature: " + celsiusTemp;
}
public void setDegrees(float degree)
{
temp = degree;
}
public char setScale()
{
'F' = fahrenheitTemp;
'C' = celsiusTemp;
}
}
now here is what my driver class looks like:
public class TempConverter
{
public static void main(String[] args){
Degree degree1 = new Degree(2);
double fahrenheitTemp;
double celsiusTemp;
fahrenheitTemp = degree1.fahrenheitTemp();
System.out.println("The Fahrenheit Temperature is " + fahrenheitTemp);
celsiusTemp = degree1.celsiusTemp();
System.out.println("The Celsius Temperature is " + celsiusTemp);
}
}
and here is a full discription of the assignment
Write a Temperature class that respresents temperatures in degrees in both Celsius and Fahrenheit. Use a floating-point number for the temperature and a character for the scale: either ‘C’ for Celsius or ‘F’ for Fahrenheit. The class should have
•Four constructors: one for the number of degrees, one for the scale, one for both degrees and the scale, and one default constructor. For each of these constructors, assume zero degrees if no value is specified and Celsius if no scale is given.
•Two accessor methods: one to return the temperature in degrees Celsius, the other to return it in degrees Fahrenheit. Use these formulas: C = 5/9(F – 32) and F=9/5 * C + 32
•Three set methods: one to set the number of degrees, one to set the scale, and one to set both
•One comparison method to test whether 2 temperatures are the same
•One toString to print out one line that describes the temperature
Write a driver program that tests all the methods. Be sure to invoke each of the constructors, to include at least one case where the 2 temperatures are the same and one where they are different.
IF ANYONE WULD BE ABLE TO HELP ME WITH MY ERRORS IN MY CONSTRUTOR METHOD OR AS LEAST LET ME KNOW WHAT I DID WRONG THAT WOULD GREATLY BE APPRECIATED......