forked from CodeToExpress/dailycodebase
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFizzbuzz.java
More file actions
28 lines (24 loc) · 715 Bytes
/
Fizzbuzz.java
File metadata and controls
28 lines (24 loc) · 715 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/**
* @author: MadhavBahlMD
* @date: 20/12/2018
*/
import java.util.Scanner;
public class Fizzbuzz {
public static void main(String[] args) {
System.out.println("/* ===== Fizz Buzz ===== */");
Scanner input = new Scanner(System.in);
System.out.print("\nEnter a number: ");
int n = input.nextInt();
for (int i=1; i<=n; i++) {
if (i%3 == 0 && i%5 == 0) {
System.out.println("FizzBuzz");
} else if (i%3 == 0) {
System.out.println("Fizz");
} else if (i%5 == 0) {
System.out.println("Buzz");
} else {
System.out.println(i);
}
}
}
}