1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
kotegsom [21]
3 years ago
13

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++; }
Computers and Technology
1 answer:
Nataly_w [17]3 years ago
6 0

Answer:

The correct code to the given question is

if ((counter % 10) == 0)  // check the condition

{

System.out.println("Counter is divisible by ten: " + counter);  // display

}

else  // check the condition

{

System.out.println("Counter is not divisible by ten: "  +counter); // display the //value

}

counter++; // increment the value of counter

Explanation:

Following are the description of code

  • In the given question we have to check the condition that the given number is divisible by 10 or not .
  • In the if block if the number is divisible by 10 then it print the value of number and increment the value of counter .
  • In the else block if the number is not divisible by 10 then it print the value of number and increment the value of counter .
  • It means the value of counter is increases in the if block as well as in the else block .So we have to remove the counter statement from there and place outside the if and else block .

You might be interested in
1. What is hydrolics?​
Mice21 [21]

Answer: Mechanical machines that use liquids to move.

7 0
3 years ago
All of the Internet in your country disappears. What happens next?
Talja [164]

Answer:

It is most likely that in a tech surrounded environment there would be an apacolypse, not necessarily a man hunting man apacolypse but it would cause a huge panic throughout that country because government could not communicate which is what leaves people with a safeplace.

Explanation:

please mark as brainliest xx hope it helps <3

if you really like this topic watch into the forest on netflix, it has the same premise except its not that internet disappears its electricity.

4 0
3 years ago
When storing used oil, it needs to be kept in ___________ containers.
tester [92]

Answer:

Plastic container

Explanation:

because if we use iron it may rust and oil may also damage

5 0
3 years ago
What is a perfect hashing function?
antiseptic1488 [7]

Answer:

First we understand what is hash function.A hash function is mostly used in Hashmaps. It maps different keys to a set of values.There may occur a case when we have same key but different values.This case is called collision.So we have to use different collision handling techniques that are open addressing and separate chaining.

A perfect hash function maps key-value pair such that there are no collisions.

3 0
3 years ago
In a PivotTable, how can a field of data be hidden from the viewer but still be active in calculations made by Excel’s formulas?
Nuetrik [128]
C. The user can select a cell in that field and click “collapse entire field” in the options tab. Is probably not right!
5 0
3 years ago
Other questions:
  • What are five features of word 2016 you would use to capture the attention of the target audience? Defend you decisions
    9·1 answer
  • The max-age attribute of a cookie is specified in
    13·1 answer
  • Which tab provides commands for the most commonly used elements in Word software?
    15·1 answer
  • A Silicon Valley billionaire purchases 3 new cars for his collection at the end of every month. Let a_n denote the number of car
    8·1 answer
  • A. Draw a flowchart or write pseudocode to represent the logic of a program that allows the user to enter an hourly pay rate and
    8·1 answer
  • Blank includes websites that encourage interaction and connection among people businesses and organizations
    14·2 answers
  • A program called a ( n ) ____ translates instructions written in high-level languages into machine code.
    13·1 answer
  • What will the following code display?
    12·1 answer
  • Edhesive 7.6 lesson practice python
    11·1 answer
  • You are a teaching assistant for an introductory computer concepts course at your local community college. The instructor asks y
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!