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]
3 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:
meriva3 years ago
5 0

Answer:

Move the duplicated code outside of the if statement

You might be interested in
What (if any) are the same feature requirements that might be found in server software/OS environments
Makovka662 [10]

The same feature requirements that might be found in server software/OS environments

They include:

  • Server Hardware Requirements  such as  Quad-Core 2 Ghz or much more high,  8 GB RAM  or more  and also free disk space.

<h3>What are the software requirements for a server?</h3>

The Software requirements for any given database server includes;

  • Database server
  • Operating system, etc.

Some of the key features of the key server operating system is made up of: the capability to access the server when using either GUI and command-level interface. the ability to execute all or a lot of processes from OS commands and others.

Learn more about software/OS environments from

brainly.com/question/26424062

#SPJ1

4 0
2 years ago
When a project manager can look at the progress towards the goals set, this is considered...?
Advocard [28]

project strategic planning

6 0
3 years ago
Read 2 more answers
Thumbnails in the picture gallery display the more common color saturation, color tone, and recolor adjustments. true or false.
jeka94
<span>Thumbnails in the Picture gallery display the more common color saturation, color tone, and recolor adjustments. TRUE. It is TRUE</span>
5 0
3 years ago
What does pagination mean in Microsoft Word?
marin [14]

it means to alt f4 then that would help so it can eat the microscope then have it digested

5 0
3 years ago
Read 2 more answers
Write a C program to insert and delete values from a stack(to perform pop and push operations) using an array data structure
Bumek [7]
<h2>Answer:</h2>

#include<stdio.h>

// Method to insert a value into a stack

void push(char value, char myStack[], int *top, int sizeOfStack){

   if(*top == -1){

       myStack[sizeOfStack - 1] = value;

       *top = sizeOfStack - 1;

   }

   else if(*top == 0){

       printf("Stack is full. \n");

   }

   else{

       myStack[(*top) - 1] = value;

       (*top)--;

   }

}

//Method to remove a value from a stack

void pop(char myStack[], int *top, int sizeOfStack){

   if(*top == -1){

       printf("Stack is empty. \n");

   }

   else{

       printf("Value removed: %c \n", myStack[(*top)]);

       // Now if the value removed was the last value in the stack

       // you should set top to -1.  

       // This would show that the stack is now empty

       if((*top) == sizeOfStack - 1){

           (*top) = -1;

       }

       else{

           (*top)++;

       }

   }

}

//Method to test the pop and push methods

int main() {

 //variable to hold the size of stack

 int sizeOfStack = 6;

 //create the stack

 char myStack[sizeOfStack];

 

 //set the top to -1

 //this is to show that the stack is initially empty

 int top = -1;

 //insert a value tot the stack

 push('x', myStack, &top, sizeOfStack);

 //print the value on the top

 printf("Value on top of stack: %c\n", myStack[top]);

 //insert another value to the stack

 push('y',myStack, &top, sizeOfStack);

 //print the value on the top of the stack

 printf("Value on top of stack: %c\n", myStack[top]);

 //insert another value to the stack

 push('z',myStack, &top, sizeOfStack);

 //print the value on the top of the stack

 printf("Value on top of stack: %c\n", myStack[top]);

 //remove the last inserted value

 pop(myStack, &top, sizeOfStack);

 //print the value on the top of the stack

 printf("Value on top of stack: %c\n", myStack[top]);

 //remove another value

 pop(myStack, &top, sizeOfStack);

 //print the value on the top of the stack

 printf("Value on top of stack: %c\n", myStack[top]);

 return 0;

}

<h2>Sample Output:</h2>

Value on top of stack: x

Value on top of stack: y

Value on top of stack: z

Value removed: z  

Value on top of stack: y

Value removed: y  

Value on top of stack: x

<h2>Explanation:</h2>

The code above has been written in c and it contains comments explaining important parts of the code. Please go through the comments.

It also contains a sample output resulting from the run of the program.

4 0
3 years ago
Other questions:
  • Which is the lowest Complexity"
    15·1 answer
  • R15. Suppose there are three routers between a source host and a destination host. Ignoring fragmentation, an IP datagram sent f
    8·1 answer
  • You are considering creating a mobile app. Describe a basic statement for the app you would create and whether your app should b
    7·1 answer
  • Question 14 (3 points)
    5·1 answer
  • Write a C++ program that allows the user to enter double values. Display one of two messages: "The first number you entered is l
    9·1 answer
  • List the caveats to this analysis and how they affect the research. How does this document define the ""typical game developer""
    7·2 answers
  • What is the most important person and why
    10·1 answer
  • Compare and contrast sources and types of credit, including costs and benefits of installment
    15·1 answer
  • Select the correct answer.
    8·1 answer
  • A user wants to print a spreadsheet horizontally on a piece of paper instead of vertically to fit more columns on a single page.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!