Expressions.java - public class Expressions cfw public static void main(String args cfw int a = 3 int b = 4 int c = 5 int d = 17 System.out.println(a b

Expressions.java - public class Expressions cfw public...

This preview shows page 1 out of 1 page.

public class Expressions { public static void main(String[] args) { int a = 3; int b = 4; int c = 5; int d = 17; System.out.println((a + b)/ c); // 3 and 4 are added with sum 7 // 7 is divided by 5 with quotient 1 System.out.println(a + b / c); // 4 is divided by 5 with quotient 0 // 3 is added to 0 with sum 3 System.out.println(a++); // 1 is added to 3 with sum 4 // However, I don't understand how when I run this the answer is 3 System.out.println(a--); // 1 is subtracted from 3 with answer of 2 //Again, I don't understand how this is equal to 4 System.out.println(a + 1); // 3 and 1 are added with sum 4 System.out.println(d % c); // 17 is divided by 5 which equals 3 with a remainder of 2 System.out.println(d / c); // 17 is divided by five with quotient 3 System.out.println(d % b); // 17 is divided by 4 which equals 4 with a remainder of 1
Image of page 1

You've reached the end of your free preview.

Want to read the whole page?

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture