Java: Different output than given in the result
Go to solution
Solved by reniat,
I think this loop is MEANT to be division. some minor tweaks and:
//declare Variables int dividend, divisor, remainder, quotient; //initialize Variables dividend = 23; divisor = 5; remainder = 0; quotient = 0; remainder = dividend; while (remainder >= divisor) { remainder = remainder - divisor; quotient++; } //Output System.out.println(dividend + " " + divisor + " " + quotient + " " + remainder);
So perhaps the professor just had the conditional wrong in the while loop, and it should actually be help >= d2 instead of help >= d1? I don't see what the original could be trying to accomplish, since it would always terminate after only 1 loop assuming only positive numbers.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now