III.Coding (each 6 pts) int numbers 100; while (number 6) System.out.println(\"c
ID: 3592576 • Letter: I
Question
III.Coding (each 6 pts) int numbers 100; while (number 6) System.out.println("current number is:" + number); number (4pts) Q1: Rewrite the above code with "for" loop: (2pts) Q2: What is the final value for "number" variable 2. public class Test static int x; public static void main(Stringl] args) t String name"JAVA" switch (name)( case "John" : x+ 2; case "Bob" x-2; break; case "JAVA" x- default : x+ break; System.out.print (x); Q1: rewrite the above code with "if -else" statement: Q2: what is the final value for "x" variableExplanation / Answer
1)
int number;
for (number = 100; number > 6; number--)
{
System.out.println("current number is:" + number );
}
b) The final value of number would be 6
2)
public class Test
{
static int x;
public static void main(String[] args)
{
String name = "JAVA";
x = 1;
if (name == "John")
{
x += 2;
}
else if (name == "Bob")
{
x -= 2;
}
else if (name == "JAVA")
{
x--;
}
else
{
x++;
}
System.out.println(x);
}
}
b) The final value for x would be 0