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).
public class CountByFives {
public static void main (String args[]) {
// Write your code here
}
}

Respuesta :

Answer:

Replace the comment

//Write your code here

with

for(int i =5; i<=500;i++){

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

if(i%50 == 0){

System.out.println();

}

}

Explanation:

See attached for the full program

This line iterates from 5 to 500

for(int i =5; i<=500;i++){

This prints each digit

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

The following if condition checks if current digit is a multiple of 5; if yes, a line is printed

if(i%50 == 0){

System.out.println();

}

}

Ver imagen MrRoyal
Q&A Education