Java help

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

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);}
}

}
 
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)
 
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!
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

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 807,865 other people just like you!

Latest posts

Top