Results 1 to 5 of 5
- 01-17-2012, 09:25 AM #1
Member
- Join Date
- Jan 2012
- Posts
- 2
- Rep Power
- 0
debugging
hi, i am a new programmer to java. with my program, i seem to have one error that i have no idea how to fix(assuming everything else works the way i
want it too.) What happens is that i was making a program to convert celsius to fahrenheit and vice versa based on the input of the user. the error
message i get is that "it cannot find a symbol" during the compiling process. The compiler keeps on singling out the temperature object, but i don't know
why.
any ideas
Java Code:public class temperature { public int degree, cel, fahren; public String units; public void temper() { degree = 0; units = "NONE"; } public String getUnits() { if(units.equalsIgnoreCase("C")) units = "Celsius"; else if(units.equalsIgnoreCase("F")) units = "Fahrenheit"; return units; } public int getDegree() { return degree; } public int getCel() { cel = (degree - 32) * (5/9); return cel; } public int getFahren() { fahren = (degree *(9/5) + 32); return fahren; } public String toString() { String temp = "You have entered " + degree + " " + units; return temp; } }Java Code:import java.util.Scanner; public class testTemp { public static void main(String[] args) { temperature t1 = new temper(); Scanner keyboard = new Scanner(System.in); boolean exit = false; while (!exit) { System.out.println("Enter 'Y' for temperature conversion, 'N' to exit."); String response = keyboard.nextLine(); if (response.equalsIgnoreCase("y")) { System.out.println("enter the temperature."); t1.degree = keyboard.nextInt(); System.out.println("Enter 'C' if the degree is in Celsius, Enter 'F' if the degree is in Fahrenheit."); t1.units = keyboard.nextLine(); if(response.equalsIgnoreCase("C")) { System.out.println(t1.toString()); System.out.println("In Fahrenheits, the degree is " + t1.getFahren()); } else if(response.equalsIgnoreCase("F")) { System.out.println(t1.toString()); System.out.println("In Celsius, the degree is " + t1.getCel()); } else if(response.equalsIgnoreCase("n")) exit = true; } } } }
- 01-17-2012, 10:22 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,476
- Rep Power
- 16
Re: debugging
You need to post the error you are getting, and highlight the line(s) it is occurring on.
People won't copy and paste this code into their IDEs just to see what the problem is.
- 01-18-2012, 08:15 AM #3
Member
- Join Date
- Jan 2012
- Posts
- 2
- Rep Power
- 0
Re: debugging
ok, so the debugger is reading an error on the temperature class. It is highlighting on the line with "temperature t1 = new temper();" saying that it cannot find symbol. I don't understand why..
- 01-18-2012, 08:56 AM #4
Member
- Join Date
- Sep 2011
- Location
- Mumbai, India
- Posts
- 35
- Rep Power
- 0
Re: debugging
Because there is no temper class its temperature class
Last edited by Rameshwar Soni; 01-18-2012 at 08:59 AM.
- 01-18-2012, 11:02 AM #5
Re: debugging
rename temper() and make a constructor termperature like
public temperature()
{
degree = 0;
units = "NONE";
}
and inside testTemp change t1 to
temperature t1 = new temperature();
Similar Threads
-
help debugging
By mluu510 in forum New To JavaReplies: 3Last Post: 08-21-2010, 01:28 PM -
Debugging Help Needed
By vittoire in forum New To JavaReplies: 3Last Post: 01-26-2010, 05:31 PM -
Debugging
By daro in forum EclipseReplies: 0Last Post: 07-22-2009, 05:02 PM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks