Results 1 to 6 of 6
- 04-22-2010, 03:20 AM #1
Member
- Join Date
- Apr 2010
- Posts
- 4
- Rep Power
- 0
unexpected type on a subtraction sign?
I am trying to make a program that runs through the numbers 0-100 and finds all the values that could stand in as x,y, or z in this equation:
4x + 3y - 9x = 5
Here's what i have:
The only error I get is "unexpected type"Java Code:/** * AWT Sample application * * @author: JanieRae * @version 1.00 10/04/20 */ public class XYZ { public static void main(String[] args) { int x = 1; int y = 1; int z = 1; for (x=1;x<100;x++) { for (y=1;y<100;y++) { if ((4*x)+(3*y)-(9*z)=5); System.out.println("4*"+x+"+3*"+y+"-9*"+z+"=5"); for (z=1;z<100;z++) { } } } } }
when i go to the detailed build report it says:
"unexpected type
required: variable
found : value
if ((4*x)+(3*y)-(9*z)=5);
^
1 error
Process completed."
(the arrow is underneath the subtraction sign)
but it's a subtraction sign... can someone please tell me what i'm doing wrong?
Thanks
-JanieRae
-
1) Please fix your indents as bad indentation makes code hard to read and will decrease your chances of getting good help.
2) Your code is messing up on having a single = in the if boolean statement (an assignment operator) rather than a double == operator.
3) You really really don't want that semicolon after the if boolean check as it will short-circuit your code. Bad.
4) Are you sure you want the if where it's located and not within the inner z loop?
- 04-22-2010, 03:59 AM #3
Member
- Join Date
- Apr 2010
- Posts
- 4
- Rep Power
- 0
I'm sorry, I'll fix that. Thank you for the advice :)
- 04-22-2010, 04:04 AM #4
Member
- Join Date
- Apr 2010
- Posts
- 4
- Rep Power
- 0
Even after fixing what you suggested, I still get the same error =\
-
- 04-22-2010, 04:09 AM #6
Member
- Join Date
- Apr 2010
- Posts
- 4
- Rep Power
- 0
Similar Threads
-
date subtraction
By silversurfer2in in forum New To JavaReplies: 6Last Post: 02-12-2010, 02:51 PM -
Error: unexpected type
By silvia in forum New To JavaReplies: 3Last Post: 02-05-2010, 09:54 PM -
Unexpected characters using PrintWriter
By mjwoodford in forum New To JavaReplies: 1Last Post: 09-18-2009, 06:09 PM -
unexpected type
By one in forum New To JavaReplies: 13Last Post: 01-20-2009, 09:32 AM -
Unexpected Error
By Mir in forum New To JavaReplies: 10Last Post: 07-07-2008, 07:57 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks