Write a program to print all numbers from 1 to 30. If the number is a multiple of 13, print the string "lucky number" instead of the number.
public class luckynumber{ public static void main(String [] args) { String str="lucky number"; for(int i=1;i<=30;i++) { if(i%13==0) { System.out.print(str+ " " ); } else System.out.print(i+ " "); } } }
No comments:
Post a Comment