Very Newb to Java with For Loop problem

• 11-05-2012, 12:34 AM
burban
Very Newb to Java with For Loop problem
I am making a program for class and after reading the book and searching online I am completely stuck on loops! Can someone look at this and tell me where I am messing up? The loop needs to show the gross sales potential with increments of 5000 to 50% of the actual sales. Everything else has worked except the loop.

thanks for any help

Error is
Illegal start of expression

cannont find symbol: variable number
location: classSalesComensation

unexpected type
required: variable
found: value

Code:

```package sales.compensation; /*  * To change this template, choose Tools | Templates  * and open the template in the editor.  */ import java.util.Scanner; /**  *  * @author Raymond  */ public class SalesCompensation {     public static void main(String[] args) {         Scanner input = new Scanner(System.in);         int number1; //total sales         double number2; // .06         double comission; // comission is 6 percent of sales         double salary; // \$120,000 is salespersons base         double gross; // gross income is salary plus comission         double target; // target sales is 500000         double targetmet; // if target is met 1.25         int p; // potential sales in 5000 increments                                 System.out.println("Sales Compensation Calculator");         System.out.println("Please Enter Total Sales");         number1 = input.nextInt(); // salesperson inputs sales         target = 500000; // target sales number         if (number1 >= target);{ // if target sales is met         number1 *= 1.25;} // accelerator is 1.25         number2 = (.06); // percent commission       comission = number1 * number2; // total commission       salary = (120000); // base salary       gross = salary + comission; // gross annual pay                 System.out.println("Comission is " + comission);         System.out.println("Gross Income is " + gross);       for (number = gross; gross + 50%; ++5000)            //now I have tried using counter and other options here, I am just lost {   system,out.printin("Potential Sales Earnings"counter); }         }    }```
• 11-05-2012, 12:45 AM
pbrockway2
Re: Very Newb to Java with For Loop problem
Hi burban, welcome to the forums! I have added "code" tags to your post. Put [code] at the start of any section of code and [/code] at the end - that way the indents and other formatting will be preserved by the forum software.
• 11-05-2012, 01:04 AM
burban
Re: Very Newb to Java with For Loop problem
Ok cool, I didnt know that.

Thanks
• 11-05-2012, 01:06 AM
osalama
Re: Very Newb to Java with For Loop problem
Hello,

First you have these syntax errors
corrections are embedded in your code in red

the loop syntax needs restructuring this is the structure of a for loop:
The syntax of a for loop is:

for(initialization; Boolean_expression; update)
{
//Statements
}

more in this link :Java Loops - for, while and do...while
review this link and see how you can adopt this structure for the loop you need

for (number = gross; gross + 50%; ++5000)
// now I have tried using counter and other options here, I am just lost

{
system,out.printin (System.out.println("Potential Sales Earnings" );) ("Potential Sales Earnings"counter);
}

the problem even with correct syntax is that "counter"is an unidentified variable, you need to define it, or choose the value you want to be printed in the loop from your existing variables