Results 1 to 5 of 5
Like Tree1Likes
  • 1 Post By Tolls

Thread: debugging

  1. #1
    vanotd21 is offline Member
    Join Date
    Jan 2012
    Posts
    2
    Rep Power
    0

    Default 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;
    			}
    		}
    	}
    }

  2. #2
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,942
    Rep Power
    19

    Default 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.
    Eranga likes this.

  3. #3
    vanotd21 is offline Member
    Join Date
    Jan 2012
    Posts
    2
    Rep Power
    0

    Default 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..

  4. #4
    Join Date
    Sep 2011
    Location
    Mumbai, India
    Posts
    35
    Rep Power
    0

    Default Re: debugging

    Because there is no temper class its temperature class
    Last edited by Rameshwar Soni; 01-18-2012 at 08:59 AM.

  5. #5
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    5

    Default 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

  1. help debugging
    By mluu510 in forum New To Java
    Replies: 3
    Last Post: 08-21-2010, 01:28 PM
  2. Debugging Help Needed
    By vittoire in forum New To Java
    Replies: 3
    Last Post: 01-26-2010, 05:31 PM
  3. Debugging
    By daro in forum Eclipse
    Replies: 0
    Last Post: 07-22-2009, 05:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •