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
NeX [460]
2 years ago
11

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
1 answer:
meriva2 years ago
5 0

Answer:

Move the duplicated code outside of the if statement

You might be interested in
To see all of the records at once, you should use _______ view. 
OverLord2011 [107]
D. Table I hope this helps
4 0
3 years ago
Read 2 more answers
Which mistakes are NOT highlighted by the spell checker in a word-processing document?
vagabundo [1.1K]
Fragments,Incorrect use of grammar,etc.
8 0
3 years ago
Read 2 more answers
Write the definition of a function reverse, whose first parameter is an array of integers and whose second parameter is the numb
GrogVix [38]

Answer:

The c++ function for reversing an array is given. The function is declared void since it returns no value.

void reverse( int arr[], int len )

{

   int temp[len];

   for( int k = 0; k < len; k++ )

   {

       temp[k] = arr[k];

   }

   for( int k = 0, j = len-1; k < len, j>= 0; k++, j-- )

   {

           arr[k] = temp[j];

    }

}

Explanation:

The reverse function uses another array to reverse the elements of the original array.

An integer array is declared, temp[len], having the same length as the input array.

int temp[len];

To begin with, the elements of the input array are copied in the temp array.

for(int k = 0; k < len; k++ )

{

       temp[k] = arr[k];

}

Next, the elements of the input array are given new value.

The temp array, in reverse order, is copied into the input array.

for( int k = 0, j = len-1; k < len, j>= 0; k++, j-- )

{

           arr[k] = temp[j];

}

The above for loop makes use of two variables simultaneously.

While the array, arr is proceeding from first element to the next, the array temp begins with the last element and goes down to the previous element.

Now, the input array, arr, contains the elements in reverse order.

The complete program is given.

#include <iostream>

using namespace std;  

 

void reverse( int arr[], int len );

void reverse( int arr[], int len )

{

   int temp[len];

   

   for(int k = 0; k < len; k++ )

   {

       temp[k] = arr[k];

   }

   

   for( int k = 0, j = len-1; k < len, j>= 0; k++, j-- )

   {

           arr[k] = temp[j];

   }

   

}

int main()  

{

   int len = 5;    

   int arri[len];    

   for( int l = 0; l < len; l++ )

   {

       arri[l] = l;

   }

   

   reverse( arri, len );    

   return 0;

}

8 0
2 years ago
You are running an application in Google App Engine that is serving production traffic. You want to deploy a risky but necessary
ziro4ka [17]

Answer:

You need to split the traffic to your test version.

Explanation:

Google app engine has a built-in feature that allows you to split a small fraction of your traffic to your test version.

You can split traffic using an IP address, so when the app receives a request, it can hash the Ip to a value between 0 to 999, and use it to re-route the request.

This way you don't need to stop your service during your tests and also avoid any risk involved with it.

6 0
3 years ago
For a new version of processor, suppose the capacitive load remains, how much more energy will the processor consume if we incre
xxMikexx [17]

Answer:

72.80 % more energy will be consumed.

Explanation:

First of all, let us have a look at the formula of energy for a processor.

E = CV^2f

Where, E is the energy

C is the capacitance

V is the voltage and

f is the clock rate.

Let E_1 be the energy of older processor.

C_1 be the capacitance of older processor.

V_1 be the voltage of older processor

f_1 be the capacitance of older processor

So, E_1 = C_1V_1^2f_1 ....... (1)

and

Let E_2 be the energy of newer processor.

C_2 be the capacitance of newer processor.

V_2 be the voltage of newer processor

f_2 be the capacitance of newer processor

E_2 = C_2V_2^2f_2 ....... (2)

Dividing equation (2) with equation (1):

\dfrac{E_2}{E_1} = \dfrac{C_2V_2^2f_2}{C_1V_1^2f_1}

As per given statement:

C_1=C_2

V_2=1.2\times V_1

f_2=1.2\times f_1

Putting the values above:

\dfrac{E_2}{E_1} = \dfrac{C_1\times (1.2V_1)^2\times 1.2f_1}{C_1V_1^2f_1}\\\Rightarrow \dfrac{E_2}{E_1} = \dfrac{(1.2)^2\times 1.2}{1}\\\Rightarrow \dfrac{E_2}{E_1} = 1.728\\\Rightarrow \bold{E_2 = 1.728 \times E_1}

Energy consumed by newer processor is <em>1.728 </em>times the energy consumed by older processor.

OR

<em>72.80 %</em> more energy will be consumed by the newer processor.

4 0
3 years ago
Other questions:
  • Ten 9600-bps lines are to be multiplexed using TDM. a. Ignoring overhead bits in the TDM frame, what is the total capacity requi
    6·1 answer
  • What is the part of the computer system that receives inputs, directs those inputs to the processor, and redirects the processed
    14·1 answer
  • Write the following function without using the C++ string class or any functions in the standard library, including strlen(). Yo
    12·1 answer
  • An
    9·1 answer
  • How does the Rights Management Services feature help to protect information
    11·1 answer
  • Demographics refers to
    7·1 answer
  • The ______ printers are the most popular type of printer in small office/home office and large office environments.
    5·1 answer
  • Read each of the following statements about Computer Science and explain why you think that statement is true.
    9·1 answer
  • You have a filtered dataset for Customer Sales with some null value rows. You want to remove these rows completely. How will you
    15·1 answer
  • A field value is currently not in any group. what happens when you try adding it to an existing group?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!