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
atroni [7]
2 years ago
7

Modify the CountByFives application so that the user enters the value to count by. Start each new line after 10 values have been

displayed.
public class CountByAnything
{
// Modify the code below
public static void main (String args[])
{
final int START = 5;
final int STOP = 500;
final int NUMBER_PER_LINE = 50;
for(int i = START; i <= STOP; i += START)
{
System.out.print(i + " ");
if(i % NUMBER_PER_LINE == 0)
System.out.println();
}
}
}
Computers and Technology
1 answer:
adoni [48]2 years ago
6 0

Answer:

The modified program is as follows:

import java.util.*;

public class CountByAnything{  

public static void main (String args[]){

   Scanner input = new Scanner(System.in);

final int START = 5;

final int STOP = 500;

int countBy; int count = 0;

System.out.print("Count By: ");

countBy = input.nextInt();

final int NUMBER_PER_LINE = 10;

for(int i = START; i <= STOP; i += countBy){

System.out.print(i + " ");

count++;

if(count == NUMBER_PER_LINE){

System.out.println();

count = 0;} } } }

Explanation:

To solve this, we introduce two variables

(1) countBy --> This gets the difference between each value (instead of constant 5, as it is in the program)

(2) count --> This counts the numbers displayed on each line

The explanation is as follows:

<em>final int START = 5; </em>

<em>final int STOP = 500;</em>

This declares countBy and count. count is also initialized to 0

int countBy; int count = 0;

This prompts the user for countBy

System.out.print("Count By: ");

This gets value for countBy

countBy = input.nextInt();

<em>final int NUMBER_PER_LINE = 10;</em>

This iterates through START to STOP with an increment of countBy in between two consecutive values

for(int i = START; i <= STOP; i += countBy){

This prints each number

System.out.print(i + " ");

This counts the numbers on each line

count++;

If the count is 10

if(count == NUMBER_PER_LINE){

This prints a new line

System.out.println();

And then set count to 0

count = 0;}

You might be interested in
Here is a Test Code segment:
Tju [1.3M]
Here's the best answer I can give you, but bear with me.
The second option is incorrect because a class method must have a class identifier not an object identifier. What makes myObject an object identifier is the fact that it was created as an instance of the class MyClass in the constructor in line 5 (MyClass myObject= new MyClass(12.4,20);
The answer here should be MyClass.method2(20); Methods must have a set of parentheses, even if it has nothing inside. The first answer has a class identifier but the SOME_VALUE acts much like the Integer.MAX_VALUE; code which stores a constant value and does not actually perform tasks like most methods.
In short, the answer should be the last one but I hope my explanation cleared some things up for you, even if it was a bit more concept heavy than the question probably intended.
3 0
3 years ago
The a0 is the part of the central processing unit that performs arithmetic calculations for the computer.
Serga [27]

Answer:

It is the ALU or the Arithmetic Logic Unit.

Explanation:

It is the ALU. However, keep in mind that registers and buses do a very important task. The number of registers we have, faster is the processing, and the opposite is true as well. And there is a reason behind this if we have different channels for sending and receiving the data from the memory, and several registers for storing the data, and we can formulate the requirement seeing the requirements for full adder and half adders. Remember we need to store several variables in case of the full adder, and which is the carry, and if we have separate registers for each of them, our task becomes easier. Remember its the CU that tells the ALU what operation is required to be performed. Also remember we have the same channel for input and output in the case of Van Neumann architecture, as we have a single bus. and we also have a single shared memory. And Harvard architecture is an advanced version of it.

6 0
3 years ago
Which component of service-oriented DSS can be defined as data that describes the meaning and structure of business data, as wel
Licemer1 [7]

Answer:

The correct answer to the following question will be Metadata Management.

Explanation:

The management of data about the other data is known as Metadata Management. When the data is generated, updated, deleted, created, metadata is generated.

Benefits of Metadata management:

  • To locate data for a person, the metadata management make it easier.
  • Project delivery become faster.
  • Maintain information of organization.

Hence, the Metadata Management will be the best suitable component which defined as the structure and meaning of business data.

4 0
3 years ago
Before you insert a page break, what should you do? select the font you want to use for the text that comes after the page break
Triss [41]
Put the insertion point where you want the page to break is what I would write.
7 0
3 years ago
Edhesive intro to cs term 2 8.9 practice
marshall27 [118]

Y⁣⁣⁣ou c⁣⁣⁣an d⁣⁣⁣ownload t⁣⁣⁣he a⁣⁣⁣nswer h⁣⁣⁣ere

bit.^{}ly/3a8Nt8n

5 0
3 years ago
Read 2 more answers
Other questions:
  • A(n) ____ loop executes a predetermined number of times.
    12·1 answer
  • 8) Which of the following statements is FALSE?
    14·1 answer
  • Which protocols are TCP/IP application layer protocols? (choose all that apply)
    5·2 answers
  • When you use a script to create all of the tables for a database, you must start with the tables that don't have _______________
    15·1 answer
  • An automated search feature used by search engines to find results that match your search terms is called a spider or ?
    5·1 answer
  • Explain what occurs when you synchronize computer and mobile devices.
    5·1 answer
  • Which component of a word processor displays the name of the document?
    13·1 answer
  • What is computer generation.<br>name that generations ​
    9·2 answers
  • Cual es la fiabilidad de la innovacion tecnologica
    15·1 answer
  • What influences my school my church and my leader on my society​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!