Created
June 4, 2020 17:09
-
-
Save kaiimran/630af5db136ad32c77f4f3c2279e5d22 to your computer and use it in GitHub Desktop.
Write a short program that prints each number from 1 to 180 on a new line. For each multiply of 3, print "Involve" instead of the number. For each multiply of 5, print "Asia" instead of the number. For numbers which are multiply of both 3 and 5, print "InvolveAsia" instead of the number.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
public class InvolveAsia{ | |
public static void main(String []args){ | |
involveAsia(180); | |
} | |
static void involveAsia(int n) | |
{ | |
for (int i=1; i<=n; i++) | |
{ | |
String s = ""; | |
if(i % 3 == 0) | |
{ | |
s = s + "Involve"; | |
} | |
if(i % 5 == 0) | |
{ | |
s = s + "Asia"; | |
} | |
if (s == "") | |
{ | |
System.out.println(i); | |
} | |
else | |
{ | |
System.out.println(s); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment