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
What are some common security threats for our home devices and IoTs?
musickatia [10]

Answer:

  • Botnets. A botnet is a network that combines various systems together to remotely take control over a victim’s system and distribute malware.
  • A denial-of-service (DoS) attack deliberately tries to cause a capacity overload in the target system by sending multiple requests.
  • In a Man-in-the-Middle (MiTM) attack, a hacker breaches the communication channel between two individual systems in an attempt to intercept messages among them.
  • Hackers use social engineering to manipulate people into giving up their sensitive information such as passwords and bank details.
  • Ransomware attacks have become one of the most notorious cyber threats. In this attack, a hacker uses malware to encrypt data that may be required for business operations. An attacker will decrypt critical data only after receiving a ransom.

Explanation:

6 0
3 years ago
9. Which of the following will best protect your computer from viruses and hackers?
maks197457 [2]

Answer:

D

Explanation:

I believe its Antivirus software because it protects your computer from virus and hackers . If i am wrong im so sorry

Have A Good Day

4 0
2 years ago
A(an) _______ is a set of instructions that a computer follows to perform a task.
Vikentia [17]
A(an) _______ is a set of instructions that a computer follows to perform a task.Answer is Program .
I hope the answer of the question.
7 0
4 years ago
A cybersecurity analyst is currently investigating a server outage. The analyst has discovered the following value was entered f
drek231 [11]

Answer:D)Format string attack

Explanation:

Format string attack is the type of attack that causes to change the application functioning .This attack access the memory of the string library. It occurs while the submission of the string as input and then gets tested due to application command.

Other options are incorrect because these are the attacks that don't happens in the application for the alteration of the flow. Thus, the correct option is option(D).

8 0
3 years ago
If you do not want the border style to carry forward each time the enter key is pressed, you need to ____.
ANEK [815]
Hello <span>Endermss2118 </span>

Answer: If you do not want the border style to carry forward each time the enter key is pressed, you need to Clear formatting


Hope This Helps
-Chris
8 0
3 years ago
Other questions:
  • Which type of natural hazard is sometimes caused by human activity?
    6·1 answer
  • Question 4 (1 point)
    12·1 answer
  • Of the following occupations, which is predicted to have the greatest job growth?
    7·2 answers
  • _____ should be scanned for viruses
    13·2 answers
  • How many frames per second can a half duplex traditional gigabit ethernet handle?
    12·1 answer
  • What type of chart is good for single series of data​
    15·2 answers
  • Java Programming
    14·1 answer
  • NEED ANSWERS ASAP
    6·2 answers
  • PLZ HELP HELP HELP ME I NEED ANSWER MATH​
    13·2 answers
  • _____ have networked and texted all of their lives with smartphones, tablets, and high-speed Internet.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!