Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Assign4;
- import java.util.Scanner;
- public class Assignment4 {
- public static void main(String args[]) {
- int countA = 1;
- int countB = 1;
- Scanner sc = new Scanner(System.in);
- System.out.println("Enter the number of players: ");
- // Get player count
- int playerCount = sc.nextInt();
- // Create string array with length of playerCount
- String[] playerNames = new String[playerCount];
- // Get player names and store them in array
- for(int x = 0; x<playerNames.length; x++) {
- System.out.println("Enter player " + countA + "'s name: ");
- playerNames[x] = sc.next();
- countA++;
- }
- // Print player names
- for(int y = 0; y<playerNames.length; y++) {
- System.out.println("Player " + countB + "'s name: " + playerNames[y]);
- countB++;
- }}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement