www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Server-Side Development > Java
    (NOT JavaScript!)

    Java
    (NOT JavaScript!)
    For discussion of the Java programming language as it applies to the Web ( Not JavaScript ).

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 11-04-2009, 10:19 PM
    drumbum360's Avatar
    drumbum360 drumbum360 is offline
    WebGuy/Fulltime Student
     
    Join Date: Jul 2004
    Location: Wisconsin
    Posts: 158
    "illegal start of expression" help needed

    I'm trying to write a Java program that will open a .txt file and read the contents of it to do payroll. I'm new to Java and haven't been too successful at this program attempt tonight and I need some help with an error I'm getting. The error states:
    employeePayroll.java:29: ';' expected
    for (int i = 0; i+3)
    ^
    employeePayroll.java:35: illegal start of expression
    }
    ^
    2 errors

    And my code is:
    Code:
    //Imports the keyboard scanner
    import java.util.Scanner;
    //To use the classes that use a .txt file
    import java.io.*;
    
    public class employeePayroll
    {
    	public static void main(String[] args) throws IOException 
    	{  
    		String filename; //file name
    		String name; 	  //employee name
    		
    		//Create a Scanner object to read input
    		Scanner keyboard = new Scanner (System.in);
    
    		
          // Open the file.
    		FileReader freader = new FileReader("data.txt"); 
    		BufferedReader inputFile = new BufferedReader(freader); 
    		String str; 
    		// Read the first item. 
    		str = inputFile.readLine(); 
    		// If an item was read, display it and read the remaining items.
    		int i = 0;
    		for (int i = 0; i+3)
    		{
    		  System.out.println(str); 
     		  str = inputFile.readLine(); 
    		} 
    		inputFile.close();
    	}
    }
    
    //ALL DONE!
    Can you please help me figure out what is wrong? I want the JAVA to read every third line of the .txt file because those lines contain the names for the payroll.

    Thank you
    Reply With Quote
      #2  
    Old 11-05-2009, 01:40 AM
    kaafmim's Avatar
    kaafmim kaafmim is offline
    Registered User
     
    Join Date: Nov 2009
    Posts: 32
    As long as I know, for loops need to semicolons my friend, as they also need a condition to end the loop, you may use: (here the condition is i being smaller than max)

    for (i=0;i<max;i+=3) {...

    or in case you don't know where to end, you should use a while loop:

    end_achieved=0;
    i=0;

    while(!end_echieved) {
    ...
    if(we_should_finish_this_loop) end_achieved=1;
    }
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 05:14 PM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.