Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
on_off
//'main' method must be in a class 'Rextester'. //Compiler version 1.8.0_111 import java.util.*; import java.lang.*; class Rextester { public static void main(String args[]){ printOnOff(); } //Write a program that prints the numbers from 1 to 100. But for multiples of three print "On" instead // of the number and for the multiples of five print "Off". For numbers which are multiples of both // three and five print "OnOff". public static void printOnOff(){ for (int i = 1; i <= 100; i++) { if (i%3==0 && i%5==0) System.out.println("OnOff"); else if(i%3==0) System.out.println("On"); else if(i%5==0) System.out.println("Off"); else System.out.println(i); } } }
run
|
edit
|
history
|
help
0
stringkeyvalues
java.
Smallest Multiple of N with Zeros and Ones
OBF-7
Kochergina_4
post decrement
Construct Tree from Ancestor Matrix
jb6.13 varargs
Cola Machine
Increment