Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fizzbuzz algorithm using java jOptionPanel #172

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Programs/FizzBuzz.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Program to demonstrate fizzbuzz algorithm using Java joptionpane-
import javax.swing.*;
import java.util.Random;
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
String inputMessage = JOptionPane.showInputDialog("Enter a number to determine if it's fizz or buzz");
int number = Integer.parseInt(inputMessage);

if (number % 3 == 0 && number % 5 == 0) {
JOptionPane.showMessageDialog(null, "The number is FizzBuzz");
} else if (number % 3 == 0) {
JOptionPane.showMessageDialog(null, "The number is Fizz");
} else if (number % 5 == 0) {
JOptionPane.showMessageDialog(null, "The number is Buzz");
} else {
JOptionPane.showMessageDialog(null, "The number is neither Fizz nor Buzz: " + number);
}
}
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ It is very easy to contribute, you may follow these steps -
99.[RotateLinkedList](https://github.com/PrajaktaSathe/Java/blob/main/Programs/RotateLinkedList.java)-Program to demo rotating a linked list
100. [ReverseString](https://github.com/PrajaktaSathe/Java/blob/main/ReverseString.java) -Program to reverse a String using the java method substring.
101.[Overriding](https://github.com/PrajaktaSathe/Java/blob/main/Programs/Overriding.java)-Program to demo overriding in java
102. [FIZZBUZZ](https://github.com/lokytech5/Java-FizzBuzz/blob/master/src/Main.java)-Program to demo fizzBuzz algorithm using java joptionpane.

# Contributors -
## A big thank you to all our contributors!!!
Expand Down