Math: % - Why do I get an error?


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/courses/learn-java/lessons/introduction-to-java/exercises/math-2?action=lesson_resume

<In what way does your code behave incorrectly? Include ALL error messages.>
The remainder should be 2 after dividing the two numbers that you chose.

```

public class Modulo {
public static void main(String[] args) {

	int myRemainder = 12 % 6;
	System.out.println(myRemainder);

}

}

<do not remove the three backticks above>

#2

this line:

System.out.println(myRemainder);

shows you that your result is currently zero, the result should be 2.

remember that % is the modulo operator, it calculates the remainder, not the result of the division

12/6 is two, i agree, but that is not the assignment here


#3

3 posts were split to a new topic: Mudolu operator


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.