Dividing and Remainders
By: Janelle Ovalle, Aryana Ruiz, James Curd, Nicholas Regalado
Example 1:
System.out.println(int(5/3));
System.out.println((int) 5/3);
System.out.println((int)(5/3));
This outputs the integer 1
Example 2:
System.out.println(int(5%3));
System.out.println((int) 5%3);
System.out.println((int)(5%3));
This outputs the integer 2
Example 3:
System.out.println((int)(7/3));
System.out.println(7/3);
System.out.println((int)7/3);
This outputs the integer 1
Example 4:
System.out.println(int)(7%3);
System.out.println(7%3);
System.out.println((int)(7%3));
This outputs the integer 1
Example 5:
System.out.println(double (5.0/3.0));
System.out.println((double)5.0/3.0);
System.out.println((double)(5.0/3.0));
This outputs the double 1.66
Example 6:
System.out.println(double (5.0%3.0));
System.out.println((double)5.0%3.0);
System.out.println((double)(5.0%3.0));
This outputs the double 2.0
Example 7:
System.out.println((double)7.0/3.0);
System.out.println(double)(7.0/3.0));
System.out.println(double)(7.0/3.0);
This outputs the double 2.33
Example 8:
System.out.println(double (7.0%3.0));
System.out.println((double)7.0%3.0);
System.out.println(double)(7.0%3.0);
This outputs the double 1.0