1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Java help

Discussion in 'Software Development' started by spderman37, Jan 28, 2013.

Thread Status:
Not open for further replies.
Advertisement
  1. spderman37

    spderman37 Thread Starter

    Joined:
    Jan 28, 2013
    Messages:
    2
    New to Java and I'm getting a illegal start of expression at my for loop on line 52. I've tried everything to fix it and can't figure it out. Any help would be great

    package commisions.sales;

    import java.util.Scanner;
    /**
    *
    *
    */
    public class CommisionsSales {

    /**
    * @param args the command line arguments
    */
    public static void main(String[] args) {
    Scanner input = new Scanner(System.in);//show output


    CommisionsSalesTest maths = new CommisionsSalesTest();//This identifies other class

    int salary = 40000;
    int totalSales = 0;//Total Sales
    double comissionRate = 0.05;
    int totalSales2 = 40000;//sales if salesman doesn't reach 80%
    double newcomissionRate = 1.25;//bonus comission rate if target sales are reached
    double tableDoubleRate = 0.50;
    final double startingSales = totalSales;
    final double doubleSales = totalSales * tableDoubleRate;
    final double increment = 5000;

    System.out.println("Fixed Salary $40,000");//show fixed salary
    System.out.print("Enter Total Sales: ");//Employee enters their total sales

    totalSales = input.nextInt();//moves program foward

    double totalIncome = maths.doMath(salary, totalSales, comissionRate, totalSales2,newcomissionRate);
    //pulls math over from other class

    System.out.printf("Total Annual Compensation is $%s \n", totalIncome);//Display the total compensation
    //for employee

    double sales;
    double comp;

    table tables = new table();

    System.out.println("Total Sales\t\tTotal Compensation");
    System.out.println("-------------------");

    for (sales = startingSales; sales <= doubleSales; += increment)
    {
    comp = tables.getRate(sales);
    System.out.printf("%d\t\t%.1f\n",sales, comp);}
    }

    }
     
  2. andythepandy

    andythepandy

    Joined:
    Jul 2, 2006
    Messages:
    379
    When you use the += operator, the syntax is:
    Code:
    operand += operand
    
    i.e. you need something before and after the += symbol, so use the following for your loop:
    Code:
    for (sales = startingSales; sales <= doubleSales; sales+= increment)
    
     
  3. spderman37

    spderman37 Thread Starter

    Joined:
    Jan 28, 2013
    Messages:
    2
    I didn't even see that when I was trying to figure out what was wrong. Thanks!!
     
  4. andythepandy

    andythepandy

    Joined:
    Jul 2, 2006
    Messages:
    379
    No problem! It's often very hard to spot mistakes when you've written the code yourself, and as soon as someone else looks at it they see it straight away!
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1087196

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice