Question: java 4. Complete Program that accepts a list of names as arguments passed to main. The program generates 3 random numbers from 1-10 for each
4. Complete Program that accepts a list of names as arguments passed to main. The program generates 3 random numbers from 1-10 for each name, prompts the user for one of the names, then outputs the total score (sum of their random numbers) for that person. E.g. - arguments "Harry", "Ron", "Hermione", "Ginny" are passed to main System assigns 3 random numbers for each name i.e. 7 10 3 for Harry, 591 for Ron, 781 for Hermione and 6 4 2 for Ginny System: User: System: Enter a name from the list: Hermione Hermione's total score is 16 Your program must: use parallel arrays store the random numbers in a 2D array include an indexof method that returns the index of the found name, -1 if not found use an assert statement to ensure that there is at least one argument passed to main - inform the user if name is not found import java.util.Scanner; import java.util.Random; public class Program4 public static void main(String[] args) { Scanner kb = new Scanner (System.in); Random rand = new Random(); // add indexof method here
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
