public class FizzBuzzProgramme {
public static void main(String[] args) {
boolean flag;
for (int i = 1; i<=100;i++)
{
flag = false;
if (i%3==0)
{
System.out.print("Fizz");
flag = true;
}
if (i%5==0)
{
System.out.print("Buzz");
flag = true;
}
if (flag == false)
{
System.out.print(i);
}
System.out.println();
}
}
}
Java Interview Question,Java tutorial and Java related Stuffs
Monday, 12 August 2013
Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.
Subscribe to:
Post Comments (Atom)
Find Duplicate Characters In String using Java
package com.zia.test; import java.util.HashMap; import java.util.Map; import java.util.Set; public class findDuplicateCharacter { /**...
-
What is the difference between Database and Database management system? Database is a collection of interrelated data. Database management ...
-
Q- Difference Between Serialization and Externalizable interface? Serialization is Marker interface which doesnt contains any method.The i...
No comments:
Post a Comment