Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2009
    Posts
    5
    Rep Power
    0

    Default Java Error Class Help !!

    Hello friends,
    We were given this code and told to fix the error can you help me i fixed as many i could now i am left with this one and i tried to fix but cant get it -

    PHP Code:
    import java.util.Scanner;
    
    public class findTheError
    {
        public static void main (String[] args)
        {
    
    
             int yearModel1, yearModel2;  //year model for car 1&2g
             int count;
             String information1, information2;  //Car information for car1 and car2
    
            Scanner keyboard = new Scanner(System.in);
    
             //Create a Car object.
    
    		  Car car1 = new Car();
    
    		  Car car2 = new Car();
    
             //Get an information of car1 from user
    
             System.out.println(" Enter your car's name");
             information1 = keyboard.nextLine();
    
             System.out.println(" Which year model is your car?");
             yearModel1 = keyboard.nextInt();
    
    
             for(count=1; count<=8; count++)
             {
    			car1.accelerate();
    		 }
    		 System.out.println("The speed is:" + car1.getspeed());
    
             for(count=1; count<=8; count++)
             {
    			car1.brake();
    		 }
    
             System.out.println("After giving brake, the speed is:" + car1.getspeed());
    
             //Get information of car2 from user
    
             keyboard.nextLine();
    
             System.out.println(" Enter your car's name");
    		 information2 = keyboard.nextLine();
    
    		 System.out.println(" Which year model is your car?");
    		 yearModel2 = keyboard.nextInt();
    
    		 for(count=1; count<=6; count++)
    		 {
    			 car2.accelerate();
    	  	 }
    	  	 System.out.println("The speed of the car is: "+ car2.getspeed());
    
             for(count=1; count<=6; count++)
             {
    			 car2.brake();
    		 }
    		 System.out.println("After brake, the speed of the car is: "+ car2.getspeed());
    
        }
    
    }
    And the error i get is -

    PHP Code:
    C:\Users\Desktop\findTheError.java:17: cannot find symbol
    symbol  : class Car
    location: class findTheError
    		  Car car1 = new Car();
    		  ^
    C:\Users\Desktop\findTheError.java:17: cannot find symbol
    symbol  : class Car
    location: class findTheError
    		  Car car1 = new Car();
    		                 ^
    C:\Users\Desktop\findTheError.java:19: cannot find symbol
    symbol  : class Car
    location: class findTheError
    		  Car car2 = new Car();
    		  ^
    C:\Users\Desktop\findTheError.java:19: cannot find symbol
    symbol  : class Car
    location: class findTheError
    		  Car car2 = new Car();
    		                 ^
    4 errors
    
    Tool completed with exit code 1
    Thanks a lot and plzzzz help

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Do you have a Car class? If not, you may need to create one that has all the methods that this class is trying to call.

  3. #3
    Join Date
    Oct 2009
    Posts
    5
    Rep Power
    0

    Default

    Quote Originally Posted by Fubarable View Post
    Do you have a Car class? If not, you may need to create one that has all the methods that this class is trying to call.
    How to do that and what should i include in the class????

Similar Threads

  1. Replies: 14
    Last Post: 05-28-2009, 06:44 AM
  2. Class Expected error
    By Radman23 in forum New To Java
    Replies: 11
    Last Post: 01-14-2009, 05:12 AM
  3. No Class Def Found Error:
    By wrap23 in forum New To Java
    Replies: 9
    Last Post: 10-02-2008, 05:07 AM
  4. Replies: 1
    Last Post: 08-02-2007, 05:07 PM
  5. Error in class
    By ai_2007 in forum Advanced Java
    Replies: 1
    Last Post: 07-09-2007, 05:06 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
  •