hi guys i am new to java and i barly learning i got some slides that teachs java from the start i started good at declaring values like ingers, strings, etc.. and made simple programs that counts sum of two numbers and the avarge and now i am stuck at the if statments with no success.. i tried understanding it by my self by apply the codes in this exercise but no use if someone can answer this with or without explaining i would appreciate it very much atleast i will got the ideas
1. Write the if-statements(s) to perform the following:
If x is even and y is odd then print their product, otherwise if x is odd print the sum of x and y, and assign x to y.
2. Find the syntax and logical errors in the following statements and correct them:
a. The intended action is: increment x if a is less than 3
if a < 3 x = x+1;
b. The intended action is: increment a and b if a is neither 3 nor 4, otherwise decrement a and b
if (a != 3 || 4)
a = a+1
b = b+1
else a = a-1
b = b-1
3. The following code is supposed to increment a and b if a is greater or equal to 3 and less or equal to 5, otherwise a has to be decremented. Find the logical errors and correct them.
if ((a < 3) && a > 5)
a = a-1;
else a++;
b++;
4. What would be output of the following statements:
if (x < 6 || y > 4) System.out.println(“A”);
if ( x >= 8 && y < 6) System.out.println(“B”);
else
if (x < 10 ) System.out.println(“C”);
else System.out.println(“D”);
if the following assignments are in effect:
a. int x = 4, y = 7;
b. int x = 9, y = 3;
c. int x = 9, y = 10;
d. int x = 10, y = 6;
Thanks
Jeff