Prompt the user to input five pairs of numbers: A player's jersey number (0 - 99) and the player's rating (1 - 9). Store the jer sey numbers in one int array and the ratings in another int array. Output these arrays (i.e., output the roster). (3 pts) Ex:
Enter player 1's jersey number: 84
Enter player 1's rating: 7
Enter player 2's jersey number: 23
Enter player 2's rating: 4
Enter player 3's jersey number: 4
Enter player 3's rating: 5
Enter player 4's jersey number: 30
Enter player 4's rating: 2
Enter player 5's jersey number: 66
Enter player 5's rating: 9
ROSTER
Player 1 -- Jersey number: 84, Rating: 7
Player 2 -- Jersey number: 23, Rating: 4
...
1 answer:
Answer:
import java.util.Scanner;
public class Main {
public static void main (String [] args) {
int jersey_num [] = new int[5];
int rating [] = new int[5];
Scanner inStream = new Scanner(System.in);
for(int i=0; i < 5; i++){
System.out.print("Enter player " + (i+1) + "'s jersey number:");
jersey_num[i] = inStream.nextInt();
System.out.print("Enter player " + (i+1) + "'s rating:");
rating[i] = inStream.nextInt();
}
System.out.println("ROSTER");
for(int j=0; j < 5; j++){
System.out.println("Player " + (j+1) + "-- Jersey number: " + jersey_num[j] + ", Rating: " + rating[j]);
}
}
} Explanation:
The solution code is written in Java. Firstly create two array, jersey_num and rating, with int type. This is to hold the five pairs of numbers input by user (Line 6 -7).
Next, create a for loop that run for 5 iterations and in each iteration prompt user to input jersey number and rating (Line 11 -17). The input number and rating will be set to the array, jersey_num and rating, respectively.
Next, print the title "Roster" (Line 19).
Create another for loop to display the five input pair of values (Line 21 - 23).
You might be interested in
Answer:
The answer is letter C
Explanation:
Systems used by many providers require customers to share bandwidth with neighbors
<span>Dynamic disk storage provides the flexibility to logically organize disk space across one or more disk drives. a. True b. False</span>
Answer: A. It’s a robust way to find information
Explanation:
Hope this help.
THE correct answer is c 10 minuets