Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A. Write an application that counts by five from 5 through 500 inclusive, and that starts a new line after every multiple of 50 (50,

A. Write an application that counts by five from 5 through 500 inclusive, and that starts a new line after every multiple of 50 (50, 100, 150, and so on).

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

I already did part A I just need help with B

My code for Part A:

public class CountByFives { public static void main(String[] args) { for(int i=5; i<=500; i+=5) { System.out.print(i + " "); if(i%50==0) System.out.println(); } } }

Given code for B:

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();

}

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions