Question: Consider the following code snippet. What is the potential problem with the if statement? double average; average = ( g 1 + g 2 +

Consider the following code snippet. What is the potential problem with the if statement?
double average;
average =(g1+ g2+ g3+ g4)/4.0;
if (average ==90.0)
{
System.out.println("You earned an A in the class!");
}
Group of answer choices
The assignment operator should not be used within an if-statement conditional.
Using == to test the double variable average for equality is error-prone.
The conditional will not evaluate to a Boolean value.
Literals should never be used in if statement conditionals.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!