Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Intro to Java Lab 5: Random Numbers Background This lab will create a program that creates an array of random integers based on three separate

image text in transcribedimage text in transcribed

Intro to Java Lab 5: Random Numbers Background This lab will create a program that creates an array of random integers based on three separate command line args supplied to the program by the user. As you may know, command line args follow the "class" filename that we specify when we run our programs using the java command. There are three requirements for you to complete in this lab, listed below. When finished, make sure to only submit the Lab5.java file. Your output will not be exactly the same as the sample output below because the program will generate random numbers each time. Note: There is no starter file for this lab, you must create Lab5.java yourself! Exercise There are 3 basic requirements to complete the lab: 1) Make sure that the user supplied 3 arguments--let's refer to them as A, B, and C. If the user supplies less or more than 3 arguments, you must print a message saying so and exit the program using System.exit(0);. 2) Use Integer.parseInt() to convert the three command line arguments to ints. 3) Finally, create an array of length A. Then, create a loop to fill the array with random numbers between B and C. You can assume that B will always be less than or equal to C. In order to parse the String input arguments into integers, you need to use the parseInt() method from lecture. As a recap, it works like this: String number = "100"; int intNumber = Integer.parseInt(number); 1 now in Mumban is an int whose value is a 2) Use Integer.parseInt() to convert the three command line arguments to ints. 3) Finally, create an array of length A. Then, create a loop to fill the array with random numbers between B and C. You can assume that B will always be less than or equal to C. In order to parse the String input arguments into integers, you need to use the parseInt() method from lecture. As a recap, it works like this: String number = "100"; int intNumber = Integer.parseInt(number); // now, intNumber is an int whose value is 100. Sample output of a correct program looks like this: stephen anthony ellis@cloudshell:~/code/lab5 (earnest-episode-102718) $ java Lab5 10 3 4 [4, 3, 3, 3, 4, 4, 3, 4, 3, 4) stephen_anthony_ellis@cloudshell:~/code/lab5 (earnest-episode-102718) $ java Lab5 5 0 10 [3, 0, 9, 4, 6] stephen_anthony_ellis@cloudshell:~/code/lab5(earnest-episode-102718) $ java Lab5 10 90 200 [143, 95, 151, 103, 193, 187, 181, 155, 93, 1171 stephen_anthony ellis@cloudshell:~/code/lab5 (earnest-episode-102718) $ java Lab5 3 10000 20000 [13548, 14612, 105501

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

Practical Azure SQL Database For Modern Developers Building Applications In The Microsoft Cloud

Authors: Davide Mauri, Silvano Coriani, Anna Hoffma, Sanjay Mishra, Jovan Popovic

1st Edition

1484263693, 978-1484263693

More Books

Students also viewed these Databases questions

Question

What type of malware can, for example, lock up a user's computer

Answered: 1 week ago

Question

Describe the factors influencing of performance appraisal.

Answered: 1 week ago