Skip to content

Instantly share code, notes, and snippets.

@bharathmuddada
Created October 31, 2021 04:35
Show Gist options
  • Select an option

  • Save bharathmuddada/0d8c540878e739ca2bdf2d69e634b7b4 to your computer and use it in GitHub Desktop.

Select an option

Save bharathmuddada/0d8c540878e739ca2bdf2d69e634b7b4 to your computer and use it in GitHub Desktop.
FizzBuzz in Java
public class FizzBuzz {
public static void main(String [] args){
Scanner scanner = new Scanner(System.in);
System.out.println("Number");
int Number = scanner.nextInt();
if(Number%3==0 && Number%5==0)
System.out.println("FIZZBUZZ");
else if(Number%5==0)
System.out.println("FIZZ");
else if(Number%3 ==0)
System.out.println("Buzz");
else
System.out.println(Number);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment