Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

java image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Temporal Databases Research And Practice Lncs 1399

Authors: Opher Etzion ,Sushil Jajodia ,Suryanarayana Sripada

1st Edition

3540645195, 978-3540645191

More Books

Students also viewed these Databases questions