Question: What can be done to improve the following code fragment? if ( ( counter % 1 0 ) = = 0 ) { System.out.println (

What can be done to improve the following code fragment?
if ((counter %10)==0)
{
System.out.println("Counter is divisible by ten: "+ counter);
counter++;
}
else
{
System.out.println("Counter is not divisible by ten: "
+ counter);
counter++;
}
Question 14 options:
Add semicolons after the if condition and the else reserved word
Shorten variable names
Move the brackets to save several lines of code
Move the duplicated code outside of the if statement

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!