Results 1 to 6 of 6
  1. #1
    JanieRae is offline Member
    Join Date
    Apr 2010
    Posts
    4
    Rep Power
    0

    Exclamation 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:

    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++)
                      {
    
                       }
                    }
                }
            }
        }
    The only error I get is "unexpected type"
    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

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    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?

  3. #3
    JanieRae is offline Member
    Join Date
    Apr 2010
    Posts
    4
    Rep Power
    0

    Post

    I'm sorry, I'll fix that. Thank you for the advice :)

  4. #4
    JanieRae is offline Member
    Join Date
    Apr 2010
    Posts
    4
    Rep Power
    0

    Default

    Even after fixing what you suggested, I still get the same error =\

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by JanieRae View Post
    Even after fixing what you suggested, I still get the same error =\
    If you don't show what changes you've made, we have no idea how to help you.

  6. #6
    JanieRae is offline Member
    Join Date
    Apr 2010
    Posts
    4
    Rep Power
    0

Similar Threads

  1. date subtraction
    By silversurfer2in in forum New To Java
    Replies: 6
    Last Post: 02-12-2010, 03:51 PM
  2. Error: unexpected type
    By silvia in forum New To Java
    Replies: 3
    Last Post: 02-05-2010, 10:54 PM
  3. Unexpected characters using PrintWriter
    By mjwoodford in forum New To Java
    Replies: 1
    Last Post: 09-18-2009, 07:09 PM
  4. unexpected type
    By one in forum New To Java
    Replies: 13
    Last Post: 01-20-2009, 10:32 AM
  5. Unexpected Error
    By Mir in forum New To Java
    Replies: 10
    Last Post: 07-07-2008, 08:57 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
  •