menu
QAmmunity.org
Login
Register
My account
Edit my Profile
Private messages
My favorites
Ask a Question
Questions
Unanswered
Tags
Categories
Ask a Question
What is the best way 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
asked
Nov 19, 2021
56.4k
views
3
votes
What is the best way 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++; } Move the duplicated code outside of the if statement Shorten variable names Move the brackets to save several lines of code Add semicolons after the if condition and the else reserved word
Computers and Technology
high-school
Dlchet
asked
by
Dlchet
8.4k
points
answer
comment
share this
share
0 Comments
Please
log in
or
register
to add a comment.
Please
log in
or
register
to answer this question.
1
Answer
3
votes
Answer:
Move the duplicated code outside of the if statement
Zan RAKOTO
answered
Nov 24, 2021
by
Zan RAKOTO
8.5k
points
ask related question
comment
share this
0 Comments
Please
log in
or
register
to add a comment.
← Prev Question
Next Question →
Related questions
asked
Oct 16, 2021
167k
views
What is the best way 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
Vallentin
asked
Oct 16, 2021
by
Vallentin
7.4k
points
Computers and Technology
high-school
1
answer
0
votes
167k
views
asked
Jun 1, 2018
62.3k
views
What the output from the following code fragment: int t1 = 87; int t2 = 78; int larger; if( t1 > t2 ) larger = t1; else larger = t2; System.out.println( "larger: " + larger );
Dexters
asked
Jun 1, 2018
by
Dexters
8.2k
points
Computers and Technology
high-school
1
answer
0
votes
62.3k
views
asked
Nov 20, 2020
97.5k
views
What is printed out by the following code fragment? int n = 15; A) if ( 10 <= n && 20 <= n ) { System.out.println( "A" ); } else { System.out.println( "B" ); } B) if ( 10 < n || 20 < n ) { System.out.println( "C" ); } else { System.out.println( "D" ); } C) if ( n != 15 ) { System.out.println( "E" ); } else { System.out.println( "F" ); } D) if ( n == 15 ) { System.out.println( "G" ); } else { E) if ( n > 0 ) { System.out.println( "H" ); } }
Lexi
asked
Nov 20, 2020
by
Lexi
8.7k
points
Mathematics
high-school
1
answer
3
votes
97.5k
views
Ask a Question
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.
9.5m
questions
12.2m
answers
Other Questions
Seven basic internal components found in a computer tower
describe an advance in technology that makes life more enjoyable. what discoveries contribute to this technology?
Disadvantages of using animation in advertising? advantages and disadvantages of using animation for education? advantages and disadvantages of using animation in entertainment?
What is an example of a dedicated computer system?
This is science they just dont have the subject buy anyways describe interactions you have with the environment that you depend on to meet your basic needs hope u can help
Twitter
WhatsApp
Facebook
Reddit
LinkedIn
Email
Link Copied!
Copy
Search QAmmunity.org