This site requires JavaScript, please enable it in your browser!
Greenfoot back
Majorzack
Majorzack wrote ...

2015/1/7

its giving me a incompatible types error... any fixes to this?

Majorzack Majorzack

2015/1/7

#
a = Greenfoot.getRandomNumber(100); //first number
            World world;
            world = getWorld();
            world.showText(""+ a, 100, 200) ;
            
            
            b = Greenfoot.getRandomNumber(100); //second number
            world.showText(""+ b, 300, 200) ;
            
            
            c = (a + b); //answer number
           
            
            Greenfoot.delay(50);
            
            
            String inputValue = JOptionPane.showInputDialog("");
            int d = Integer.parseInt( inputValue );
            world.showText(""+ d, 500, 200) ;
            
            
            if ( d = a + b)
            {
               n= n+1;
            }
            else
            {
                n= 0;
            }
            
            world.showText(""+ n, 500, 300) ;
Majorzack Majorzack

2015/1/7

#
the error is on line 22 of the code
danpost danpost

2015/1/7

#
For the condition on line 22, you have an expression that sets the value of d to the sum of a and b. It is this value that is returned, an int value, which the 'if' statement cannot handle. It needs to have a boolean expression -- something that is either 'true' or 'false'. If you are trying to have n increment when the sum is equal to the value of d, you must use the conditional equality operator '==' (a double equal sign), not the assignment operator '=' (a single equal sign).
Majorzack Majorzack

2015/1/7

#
@danpost thank you so much. i see you on every post almost. are you a site admin or? me and my friends flipped out when you commented... you're like, famous in our programming class...
danpost danpost

2015/1/7

#
No. I am not a site admin. Nor am I in any way affiliated with greenfoot. I am just a retired person who is somewhat knowledgeable in programming and likes to help others learn. Send all donations to me -- retirement does not pay well (lol).
lordhershey lordhershey

2015/1/7

#
Dan, you should put a paypal link up for donations.
xFabi xFabi

2015/1/7

#
^ so true ^ Tho i Cant donate, not 18 yet ._. Basically, if it wasn't for you, this site would be dead, greenfoot should pay you :)
danpost danpost

2015/1/7

#
xFabi wrote...
^ so true ^ Tho i Cant donate, not 18 yet ._. Basically, if it wasn't for you, this site would be dead, greenfoot should pay you :)
If greenfoot would create an account in my name, I would not mind. In fact, they would then be entitled to a portion of the pot (if the site was not here, I could not be here).
Majorzack Majorzack

2015/1/8

#
"i am somewhat knowledgeable in programming" DUDE... YOU'RE LIKE... A GOD... YOU'RE ON EVERY POST... YOU'RE ALWAYS THERE... YOU ALWAYS HAVE THE CORRECT ANSWERS... Greenfoot should pay you because i've come to this site for help many times and you solve any problem i can think of... you're an expert in the subject... how old are you? you seem really nice. and already retired. seems like you have it figured out.
patterperson patterperson

2015/2/11

#
danpost please contact patterperson . I am also retired, short on money, and want to interest you in a joint project.
You need to login to post a reply.