Java Task #1 – Desk Checking Assume that any variables in the following code sni
ID: 3930674 • Letter: J
Question
Java
Task #1 – Desk Checking
Assume that any variables in the following code snippets have been properly declared.
Can you find the errors (if any) in the following statements and if so, what are they?
1) if (x == 1)
y=2;
else if (x==2);
y=3;
2) Count = 0;
if (COUNT == 0)
Count = COUNT + 1;
3) if (average = 100)
System.out.println(“You have a perfect grade”);
4) X==4;
X = X/2;
System.out.println(“the answer is “ + X);
5) X = A + B / C – D * E – 7 * F;
Explanation / Answer
Question 1:
Answer: Removed sem colon from else if (x==2);
1) if (x == 1)
y=2;
else if (x==2)
y=3;
Question 2:
Answer:
Count = 0;
if (Count == 0)
Count = Count + 1;
Question 3:
Answer:
if (average == 100)
System.out.println(“You have a perfect grade”);
Question 4:
Answer:
X=4;
X = X/2;
System.out.println(“the answer is “ + X);
Question 5:
Answer:
X = (A + B) / (C – D * E – 7 * F);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.