41.9k views
4 votes
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). Save the file as Count By Fives.java.

1 Answer

5 votes

Answer:

//package CountByFives.java;

import java.util.*;

import java.io.*;

class Main{

public static void main(String[] args)

{

System.out.println("Enter the maiximum number of numbers");

Scanner sq1=new Scanner(System.in);

int num =sq1.nextInt();

int i=0,n=0,a=10;

while(i <=num)

{

System.out.print(i);

i+=5;

if(n==a)

{

System.out.println('\\');

n=0;

}

n=n+1;

}

}

}

Step-by-step explanation:

Please check the answer section.

User Emilian
by
6.4k points