Cannot find symbol class, but why not?
Newbie to Java - I created a new class called Temperature and now am trying to write a class called TempDemo to test everything - but can't get past "linking" the two programs. I think I followed the format of my other programs by:
1) Naming the first program Code:
public class Temperature
2) Using the following to tell the second program to go to this class Code:
Temperature t = new Temperature();
When I do this it comes back with an error "cannot find symbol class Temperature". Can't figure this out! Here is the complete code. Thanks in advance for any help you can provide. Gary
FIRST PROGRAM
Code:
public class Temperature
{
private double tempValue;
private char scale;
//constructors
public Temperature(double tempValue)
{
this.tempValue = tempValue;
scale = 'C';
}
public Temperature(char scale)
{
tempValue = 0;
this.scale = scale;//should this be C?
}
public Temperature(double tempValue, char scale)
{
this.tempValue = tempValue;
this.scale = scale;
}
public Temperature()
{
tempValue = 0;
scale = 'C';
}
//mutators or setters
public void setTempValue(double tempValye)
{
this.tempValue = tempValue;
}
public void setScale(char scale)
{
this.scale = scale;
}
public void setBoth(double tempValue, char scale)
{
this.tempValue = tempValue;
this.scale = scale;
}
//getters
public double getTempValue() //not sure I need this but put it in so boolean works
{
double tempValue = 0;
return tempValue;
}
public double getTemperatureF()
{
double degreesF = (9 * (tempValue / 5)) + 32;
return degreesF;
}
public double getTemperatureC()
{
double degreesC = 5 *(tempValue - 32) /9;
return degreesC;
}
//boolean needed to 1) test whether two temps are equal, and 2) test if one temp is less han the other
public boolean equals(Temperature otherTemperature)
{
return(this.getTempValue() == otherTemperature.getTempValue());
}
public boolean isLessThan(Temperature otherTemperature)
{
return(getTemperatureF() < getTemperatureC());
}
public boolean isGreaterThan(Temperature otherTemperature)
{
return(getTemperatureF() > getTemperatureC());
}
//toString
public String toString()
{
return tempValue + " " + scale;
}
}
SECOND PROGRAM (HAVE NOT GOTTEN VERY FAR, I KNOW)
Code:
import java.util.*;
public class TempDemo
{
public static void main(String[] args)
{
//use all of the constructors
Temperature t = new Temperature();
}
}