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 { /**...
-
public class Program { public static int getClosestToZero(int[] a) { /* Please implement this method to return the number in...
-
public class FizzBuzzProgramme { public static void main(String[] args) { boolean flag; for (int i = 1; i
No comments:
Post a Comment