Modify the CountByFives application so that the user enters the value to count by. Start each new line after 10 values have been displayed. (Cengage Mindtap assignment).
This is the java code we are given:
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();
}
}
}
import java.util.Scanner; public class CountByAnything { public static void main (String args[]) { int START; final int STOP = 500; final int NUMBER_PER_LINE = 10; int temp = 0; Scanner scanner = new Scanner(System.in); START = scanner.nextInt(); for(int i = START; i <= STOP; i += START) { System.out.print(i + "\t"); temp++; if(temp % NUMBER_PER_LINE == 0) System.out.println(); } System.out.println(); } }
Get Answers For Free
Most questions answered within 1 hours.