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

2011/11/18

Help Quick Question

2woodsway 2woodsway

2011/11/18

#
This is the question: Write an if/else statement that adds 1 to the variable minors if the variable age is less than 18 , adds 1 to the variable adults if age is 18 through 64 and adds 1 to the variable seniors if age is 65 or older. This was my answer: if(age< 18) { minor++; } if(age>=18 && age<=64) { adults++; } if(age>=65) { seniors++; } And Yet I am getting an error, please help???
plcs plcs

2011/11/18

#
First I'd make them else if for adults and seniors, since they are all related. Towards the error you are getting, what is the error exactly? Have you created those three variables, and are they ints?
davmac davmac

2011/11/18

#
Your code says "minor" (as in "minor++"), isn't the variable supposed to be "minors"?
2woodsway 2woodsway

2011/11/18

#
very true!! thanks so much
You need to login to post a reply.