'cannot find symbol variable theCount' / 'incompatible types'


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: 'cannot find symbol variable theCount' / 'incompatible types'

  1. #1
    Join Date
    Jan 2006
    Posts
    3

    'cannot find symbol variable theCount' / 'incompatible types'

    I have spent much time trying to figure out what is wrong and am still unable to get it.

    What it should do...
    I would like it to show the name of a product, the person guess's the price, then it tells them how off they were followed by a new product.

    Thanks for the help, its much appreciated!!

    Code:
    class priceIsRight
    {
    	public priceIsRight(double guessPrice, double count)
    	{
    		double theguessPrice;
    		double theCount;
    		theguessPrice = guessPrice;
    		theCount = count;
    	}
    	
    	public String getProductName()
    	{
    		String productName;
    		
            	switch(theCount)
                {
                	case 1: 
                		productName = "HP Laptop";
                		break;
                	case 2:
                		productName = "Used HP Laptop";
                		break;
                }
    			return productName;
        }
    
    	public String getProductPrice()
    	{
    		double productPrice;
    		
            	switch(theCount)
                {
                	case 1: 
                		productPrice = 1250;
                		break;
                	case 2:
                		productPrice = 1000;
                		break;
                }
    			return productPrice;
        }
    		public String toString()
        	{
            	String result;
            	result = "";
            	result = getProductName();
            	return result;
    		}
    	
    	
    	
       public static void main (String args [])
        {
            for (int count =0; count <10; count++)
            {
            double guessPrice;
            priceIsRight myPrice = new priceIsRight(guessPrice,count);        
            System.out.println ("Guess Amount:  ");
    		guessPrice = TextIO.getInt();
                System.out.println(myPrice);
            }
        }
    }
    Cannot find symbol variable theCount
    -Line 15
    -Line 33

    Incompatible types
    -Line 42

  2. #2
    Join Date
    Dec 2005
    Location
    New Jersey
    Posts
    290
    Quote Originally Posted by Izkabola
    Cannot find symbol variable theCount
    -Line 15
    -Line 33
    You never defined a variable called theCount anywhere.
    Quote Originally Posted by Izkabola
    Incompatible types
    -Line 42
    You are returning a double in a method that is supposed
    to return a String. Either return String.valueOf(productPrice),
    or make getProductPrice() return a double.

  3. #3
    Join Date
    Jan 2006
    Posts
    3

    Thumbs up

    Thanks mate.

Similar Threads

  1. JDOM Classpath Help Required
    By kpandya in forum Java
    Replies: 5
    Last Post: 01-15-2006, 08:10 PM
  2. JDOM Errors & How to set the classpath
    By kpandya in forum Java
    Replies: 0
    Last Post: 01-14-2006, 08:01 PM
  3. Replies: 15
    Last Post: 07-28-2005, 12:14 PM
  4. SQL Tutorial (Answer Q's & post your reply)
    By bigbastard4 in forum Database
    Replies: 2
    Last Post: 05-16-2001, 07:24 PM
  5. What is the UDT?
    By Tahui in forum VB Classic
    Replies: 2
    Last Post: 11-22-2000, 11:24 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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center