Results 1 to 4 of 4
- 04-01-2011, 03:29 PM #1
Member
- Join Date
- Mar 2011
- Location
- San Diego, CA
- Posts
- 34
- Rep Power
- 0
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 program2) Using the following to tell the second program to go to this classJava Code:public class 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. GaryJava Code:Temperature t = new Temperature();
FIRST PROGRAM
SECOND PROGRAM (HAVE NOT GOTTEN VERY FAR, I KNOW)Java 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; } }
Java Code:import java.util.*; public class TempDemo { public static void main(String[] args) { //use all of the constructors Temperature t = new Temperature(); } }
- 04-01-2011, 03:37 PM #2
Senior Member
- Join Date
- Nov 2010
- Location
- Delhi
- Posts
- 135
- Blog Entries
- 1
- Rep Power
- 0
Have you compiled the first program before using it in second class.
also make sure, both programs are in same directory.
- 04-01-2011, 03:43 PM #3
Member
- Join Date
- Mar 2011
- Location
- San Diego, CA
- Posts
- 34
- Rep Power
- 0
Don't I feel like an idiot! It wasn't working because I took this project to school on a flash drive and it was saving the first program to that, and since I started the second program at home it was saving it on the hard drive. Like I said, total idiot!
- 04-01-2011, 03:57 PM #4
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
Similar Threads
-
Extended Class - Cannot Find Symbol
By javak in forum New To JavaReplies: 15Last Post: 02-27-2011, 04:43 PM -
can't find symbol
By globo in forum New To JavaReplies: 21Last Post: 01-17-2011, 04:06 AM -
cannot find symbol symbol :constructor Error. Please help! =(
By KalEl in forum New To JavaReplies: 9Last Post: 10-18-2008, 08:26 PM -
cannot find symbol symbol : class Item location: package platypos.services.order
By officialhopsof in forum New To JavaReplies: 3Last Post: 05-01-2008, 08:30 AM -
cannot find symbol class error
By po0oker in forum New To JavaReplies: 5Last Post: 10-31-2007, 02:52 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks