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
Using the find and replace tool would be most appropriate when
mafiozo [28]

A. Changing the company name when the same letter is sent to different companies

The find and replace tool is meant to help replace all instances of a certain piece of text with a different piece of text.

For example, if a letter was sent to Company A, the find and replace tool could change every time the letter says “Company A” and make it say “Company B” instead so the same letter could be sent to Company B.

3 0
3 years ago
Read 2 more answers
The creation of MySpace pages by candidates in the 2008 Presidential Election is an example of the use of ___________________ to
jarptica [38.1K]
This is descriptive of the use of mass media.
7 0
3 years ago
_________ enables customers to combine basic computing services,such as number crunching and data storage,to build highly adapta
Ghella [55]

Answer:

The correct answer to the question is option A (IaaS)

Explanation:

IaaS (Infrastructure as a Service) can be used for data storage, backup, recovery, web hosting, and various other uses as it is cost-effective, and it also has secured data centers. It is a service delivery method by a provider for cloud computing as it enables customers to be offered the service the possibility to combine basic computing services to build and direct access to safe servers where networking can also be done. These services rendered by the providers allow users to install operating systems thereby making it possible to build highly adaptable computer systems.

SaaS (Software as a Service): Here, the service provider bears the responsibility of how the app will work as what the users do is to access the applications from running on cloud infrastructure without having to install the application on the computer.

The cloud provider (CP) as the name suggests is anybody or group of persons that provide services for operations within the cloud.

7 0
3 years ago
Alex needs to create a function capable of counting item reference numbers that he is inserting into a spread sheet. The purpose
nasty-shy [4]

Answer:

Option C: Press Shift + F3 to access the Insert Function dialog box to look for a function that counts items.

is the correct answer.

Explanation:

As Alex wants to find a function that is capable of counting item reference numbers that he is inserting into a spread sheet, so she should:

  • Press Shift + F3
  • This key would present a dialogue box on the screen.
  • The dialogue box will have the option that will search for the functions inserted.
  • Item counting function will be inserted into the dialogue box and press ok.

All other options will not help Alex in the respective manner.

<h2> hope it will help you!</h2>
6 0
3 years ago
Atmospheric _______ prevents most gamma ray, x-ray, ultraviolet, and infrared light from reaching the surface of earth.
Diano4ka-milaya [45]
A. Opacity
Hope that helps.
6 0
3 years ago
Other questions:
  • Please look at picture
    10·2 answers
  • What is the type of account and normal balance of allowance for uncollectible accounts?
    13·2 answers
  • The Internet has made it possible for most people to order all of their clothing online. While this may be a preference for some
    5·1 answer
  • Trisha is looking for a new table style. What is the fastest way for her to preview how different styles in the gallery would lo
    13·1 answer
  • What type of hardware enables users to interact with a computer? Check all that apply. the CPU the hard disk drive the keyboard
    9·2 answers
  • Csc105 final graded project
    9·1 answer
  • Which of the following statements about federal student loans is true?
    7·1 answer
  • The physical parts or components of a computer system is called?
    8·2 answers
  • KAPWING Video Editing Software allows you to use existing You Tube Videos in your design.
    8·1 answer
  • Keira is creating an app for her cross-country team. Users will input their race times and the output will be a graph showing th
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!