5 Replies Latest reply on Apr 4, 2013 6:39 AM by gimbal2

# what is the way to Calculate (C) how is the result are 3

public class NewClass4 {
public static void main(String[] args) {
int a = 1;
int b = 2;
int c = 3;
a += 5;
b *= 4;
c += a * b;
c %= 6;
System.out.println("a = " + a);
System.out.println("b = " + b);
System.out.println("c = " + c);
• ###### 1. Re: what is the way to Calculate (C) how is the result are 3
Try adding more System.out statements in between to see what the results of the different calculations are; then you may figure out where you are confused.

Also: you know what the modulo ( % ) operator actually does right? If not you will want to look that up in your book. I assume you have one, since this looks very much like a homework assignment. If you don't you should really get one.
• ###### 2. Re: what is the way to Calculate (C) how is the result are 3
c += a * b;
what is the result
• ###### 3. Re: what is the way to Calculate (C) how is the result are 3
997799 wrote:
c += a * b;
what is the result
Try adding more System.out statements in between to see what the results of the different calculations are; then you may figure out where you are confused.
Also: you know what the modulo ( % ) operator actually does right? If not you will want to look that up in your book. I assume you have one, since this looks very much like a homework assignment. If you don't you should really get one.
• ###### 4. Re: what is the way to Calculate (C) how is the result are 3
997799 wrote:
c += a * b;
what is the result
What do you think it is?
• ###### 5. Re: what is the way to Calculate (C) how is the result are 3
baftos wrote:
997799 wrote:
c += a * b;
what is the result
Try adding more System.out statements in between to see what the results of the different calculations are; then you may figure out where you are confused.
Also: you know what the modulo ( % ) operator actually does right? If not you will want to look that up in your book. I assume you have one, since this looks very much like a homework assignment. If you don't you should really get one.
Deja vu!