Untitled

mail@pastecode.io avatar
unknown
plain_text
23 days ago
717 B
4
Indexable
Never
import java.util.Scanner;

public class SimpleFizzBuzz {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        System.out.println("Geben Sie die Obergrenze für FizzBuzz ein:");
        int upperLimit = scanner.nextInt();

        for (int i = 1; i <= upperLimit; 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);
            }
        }

        scanner.close();
    }
}
Leave a Comment