Use methods and a loop of your choice to develop a program that can display multiples of 10 until 150 on a single line. For example, the output should be like: 10, 20, 30, 40,…….150.
package loops;
public class Loops {
public void display(){
for(int i=10; i<=150; i++){
if(i % 10==0){
System.out.printf("%d, ", i);
}
}
}
public static void main(String[] args) {
Loops ps = new Loops();
ps.display();
}
}
Comments
Leave a comment