reached end of file while parsing

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Tony Koone

    reached end of file while parsing

    Code:
    import javax.swing.JOptionPane;  
        
    public class DistanceTraveled  
    
     {  
    public static void main(String[] args)  
    
     {  
    
     int Distance;  // D = Distance Traveled  
    
     int Speed;  // S = Speed entered by user
    
     int Time;  // T = Time entered by user
    
     String Input;  
     input = JOptionPane.showInputDialog("What is the speed " + "of the vehicle in miles-per-hour?");  
    
     Speed = Integer.parseInt(input);  
    
       
    
     while (Speed < 0)  
    
     {  
    
     Input = JOptionPane.showInputDialog("What is the speed " + "of the vehicle in miles-per-hour? " + "*Please enter a POSITIVE number*");  
    
     Speed= Integer.parseInt(input);  
    
     }  
        
    
     Input = JOptionPane.showInputDialog("How many hours " + "has the vehicle traveled for?");  
    
     Time = Integer.parseInt(Input);  
    
        
     while (Time < 1)  
    
     {  
    
     input = JOptionPane.showInputDialog("How many hours " + "has the vehicle traveled for? " + "*Please enter a value that is not less than 1*");  
    
     Time = Integer.parseInt(Input);  
    
     }      
    
     Distance = Speed * Time;  //
    
        
     System.out.println("Hour Distance Traveled");  
    
     System.out.println("------------------------");  
    
     System.out.println(Time + "\t\t" + Distance);  
    
    
     for(int Input=1; Input<=Time; Input++)  
    
     {  
    
     System.out.println("Hour " + Input + ": " + (Speed*Input) + " miles traveled");
     }
    I keep getting this message when i try to compile my program.
    reached end of file while parsing
    Can anyone tell me what's wrong?
    I do not think i have to many brackets.
    Last edited by Nepomuk; Oct 11 '10, 10:44 AM. Reason: Please use [CODE] tags
  • Dheeraj Joshi
    Recognized Expert Top Contributor
    • Jul 2009
    • 1129

    #2
    Is this code complete? I can not see the closing braces for main method and for your class.

    Regards
    Dheeraj Joshi

    Comment

    • b laxmikanth
      New Member
      • Oct 2010
      • 2

      #3
      u get this error for improper closing of ur braces

      Comment

      Working...