Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. /*
  2. * Robert Thibodeau
  3. */
  4.  
  5. package fizzbuzz;
  6.  
  7. import java.util.Scanner;
  8.  
  9. public class FizzBuzz {
  10.  
  11. public static void main(String[] args) {
  12.  
  13. Scanner input = new Scanner(System.in);
  14. System.out.println("Please enter a number.");
  15. double userin = input.nextDouble();
  16.  
  17. int result5 = (int) userin % 5;
  18. int result3 = (int) userin % 3;
  19.  
  20. if (result5 == 0)
  21. System.out.print("Fizz ");
  22.  
  23.  
  24. if (result3 == 0)
  25. System.out.print("Buzz");
  26.  
  27. else if (result3 > 0 && result5 > 0)
  28. System.out.print(userin);
  29. input.close();
  30.  
  31.  
  32. }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement