Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //i have been slowly learning Java so this is the language that I chose to do it in.
- import java.util.Scanner;
- public class PingPong {
- static Scanner userInput = new Scanner(System.in);
- public static void main(String[] args) {
- if (userInput.hasNextInt())
- {
- int numberEntered = userInput.nextInt();
- //System.out.println(numberEntered);
- int i;
- for (i = 0; i <= numberEntered; i++)
- {
- if (i == 0)
- System.out.println("0");
- else if (i % 5 == 0)
- if (i % 3 == 0) System.out.println("Ping-Pong");
- else
- System.out.println("Pong");
- else if (i % 3 == 0)
- System.out.println("Ping");
- else
- System.out.println(i);
- }
- }
- else
- {
- System.out.println("You have not entered a number");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement