1. Engineering
  2. Computer Science
  3. 7 20 points write a java class called generalizedfizzbuzz that...

Question: 7 20 points write a java class called generalizedfizzbuzz that...

Question details

(7) (20 points) Write a Java class called GeneralizedFizzBuzz that prompts a user for three integers n, p, and q, and then prints all integers from 1 to n, each on its own line, with the following exceptions (a) If the number is a multiple of p but not q, print FIZZ (b) If the number is a multiple of q but not p, print BUZZ (c) If the number is a multiple of p and q, print FIZZBUZZ The flow should look like the following: Enter n: 8 Enter p:2 Enter q: 3 FIZZ BUZZ FIZZ FIZZBUZZ FIZZ As part of your implementation, you should check that n, p, and q are not 0 or negative. (You need not worry about the case where the user enters a non-integer.) This flow should look like the following Enter n:-8 Enter a positive integer for n:0 Enter a positive integer for n:8 Enter p: 2 Enter q: -3 Enter a positive integer for q: 3 FIZZ BU2Z FIZZ FI2ZBUZZ FIZZ

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution