Results 1 to 4 of 4
  1. #1
    burban is offline Member
    Join Date
    Nov 2012
    Location
    SC
    Posts
    2
    Rep Power
    0

    Default 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

    Java 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);
    }
    
      
           }    
    }
    Last edited by burban; 11-05-2012 at 01:05 AM. Reason: code tags added

  2. #2
    pbrockway2 is online now Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,574
    Rep Power
    12

    Default 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.

  3. #3
    burban is offline Member
    Join Date
    Nov 2012
    Location
    SC
    Posts
    2
    Rep Power
    0

    Default Re: Very Newb to Java with For Loop problem

    Ok cool, I didnt know that.

    Thanks

  4. #4
    osalama is offline Member
    Join Date
    Nov 2012
    Posts
    1
    Rep Power
    0

    Default 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

Similar Threads

  1. Android Java NewB Question...
    By dmagician in forum Android
    Replies: 0
    Last Post: 06-25-2012, 12:32 PM
  2. Replies: 4
    Last Post: 09-20-2011, 04:33 AM
  3. Help for a total Java Newb
    By rsjac in forum New To Java
    Replies: 3
    Last Post: 02-21-2011, 05:30 AM
  4. An unfixable problem (very newb)
    By Kaz in forum New To Java
    Replies: 8
    Last Post: 07-09-2009, 05:49 AM
  5. Java newb Q: 8-digit id
    By 1111FM in forum New To Java
    Replies: 2
    Last Post: 09-29-2008, 03:37 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
  •