Ask your own question, for FREE!
Computer Science 7 Online
OpenStudy (a1234):

There is supposed to be at least one error in this code. Can you help me identify them?

OpenStudy (a1234):

I think it isn't supposed to say public static the second time. Are there any other errors?

OpenStudy (rsmith6559):

main() doesn't have an ending brace. Where is function getsS declared? SS isn't properly defined in getS() scope, or if it's main() SS the return statement is unneeded.

OpenStudy (a1234):

Sorry for the code I posted before...this is what we're supposed to deal with: public class Thingy { public static void main(String[] args) { int R = 10334; int SS = 4; int M = 8; int M1 = getsS(SS, R, M = 2); System.out.println("In that time there remain " + M1 + " people."); public static int getS(int SS, int R, int M) { SS = (R * M) - 4; return SS; } }

OpenStudy (a1234):

I see that a closing bracket is missing. And is it true that "public" isn't needed a second time @rsmith6559 ?

OpenStudy (spyrodie):

Assuming you don't want to gets() declared inside main so You will need a function prototype.

OpenStudy (rsmith6559):

Okay, my original comments still hold. If I remember correctly, all functions/methods need access permissions. It has to do with other objects being able to call this object (class), when you get to more Object Oriented Programming, it'll make sense.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!