Results 1 to 4 of 4
- 11-04-2012, 11:34 PM #1
Member
- Join Date
- Nov 2012
- Location
- SC
- Posts
- 2
- Rep Power
- 0
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 12:05 AM. Reason: code tags added
- 11-04-2012, 11:45 PM #2
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,561
- Rep Power
- 11
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, 12:04 AM #3
Member
- Join Date
- Nov 2012
- Location
- SC
- Posts
- 2
- Rep Power
- 0
Re: Very Newb to Java with For Loop problem
Ok cool, I didnt know that.
Thanks
- 11-05-2012, 12:06 AM #4
Member
- Join Date
- Nov 2012
- Posts
- 1
- Rep Power
- 0
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
-
Android Java NewB Question...
By dmagician in forum AndroidReplies: 0Last Post: 06-25-2012, 11:32 AM -
Sorry, I'm a newb at Java... Could someone explain something in detail for me...
By ViciousDead in forum New To JavaReplies: 4Last Post: 09-20-2011, 03:33 AM -
Help for a total Java Newb
By rsjac in forum New To JavaReplies: 3Last Post: 02-21-2011, 04:30 AM -
An unfixable problem (very newb)
By Kaz in forum New To JavaReplies: 8Last Post: 07-09-2009, 04:49 AM -
Java newb Q: 8-digit id
By 1111FM in forum New To JavaReplies: 2Last Post: 09-29-2008, 02:37 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks