Objects and Classes
okay so am having a go at teaching myself objects and classes but am losing the will to live. Am trying to create a program which converts celsius into fahrenheit (same as my earlier one) but this time writing the class then writing the method. I have a package called CelsiusTemp and two files in it; first is class
publicclass CelsiusTemp2
{
// attributes
privateint aTemperature;
// methods
publicint getTemp()
{
return aTemperature;
}
publicvoid setTemp(int temp)
{
aTemperature = temp;
}
publicdouble convertToFahrenheit()
{
return 1.8 * aTemperature + 32.0;
}
}
and the second with the methods:
import java.util.Scanner;
publicclass TemperatureTester2
{
publicstaticvoid main (String [] args)
{
Scanner myScanner=new Scanner(System.in);
CelsiusTemp cTemp=new CelsiusTemp();
int myTempC;
double myTempF;
System.out.println("Enter a temperature in degrees Celsius :");
myTempC = myScanner.nextInt();
cTemp.setTemp(myTempC);
System.out.println("A temperature of "+ cTemp.getTemp()
+"C is " + cTemp.convertToFahrenheit()+"F");
}
}
the second set of code has mistakes in it because it keeps saying:
cannot find symbol
all the books just go on instead of just showing the two sets of code and how they link together.
please help me!

