Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Generics You must use Generics when you write your program for this assignment. If I see anything similar to the following when I compile your

Generics
You must use Generics when you write your program for this assignment. If I see anything similar to the following when I compile your program, you will not receive credit for the program.
Note: .\Proj05Runner.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Proj05
Among other things, this assignment involves:
Working with Generics.
Working with collections.
PROGRAM SPECIFICATIONS
Write a program named Proj05 that uses the class definition contained in the file named Proj05.java to produce text output as described below.
Your challenge is to examine the code in the file named Proj05.java along with the output text shown below to deduce the algorithm required to produce that output and to implement that algorithm in a file named Proj05Runner.java.
The output text for any given run will depend on the input value provided as a command-line argument. The text shown below was produced by five consecutive runs of the program for input values of 1,2,3,4, and 5 respectively. I will test your program with a different undisclosed input value. You can test your program by running your version and my version side-by-side and comparing the results for any input value that you choose.
You must define a new class named Proj05Runner. For this assignment, you must submit a single source code file named Proj05Runner.java encapsulated in a zip file. It must contain the definition of a class named Proj05Runner and nothing else other than required import directives. If you fail to comply with this requirement, you will not get credit for the assignment. You may not modify the class definition for the class named Proj05.
Your program must not produce any output similar to the following:
Note: Proj05Runner.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
The purpose of Asg04 through Asg08 is to assess your ability to apply generics. It is not sufficient to simply insert the following annotation in your code to hide the warnings.
@SuppressWarnings("unchecked")
Do not include this annotation in your code.
Sample output for different command-line argument values follows:
NOTE:
Only one new class definition is allowed.
Unchecked operations are not allowed.
I certify that this program is my own work
and is not the work of others. I agree not
to share my solution with others.
Print your name here.
Input: chris Bill Chris Chris Don don don Bill
Output: don don chris Don Chris Chris Bill Bill
NOTE:
Only one new class definition is allowed.
Unchecked operations are not allowed.
I certify that this program is my own work
and is not the work of others. I agree not
to share my solution with others.
Print your name here.
Input: bill Don chris don don bill ann Ann
Output: don don chris bill bill ann Don Ann
NOTE:
Only one new class definition is allowed.
Unchecked operations are not allowed.
I certify that this program is my own work
and is not the work of others. I agree not
to share my solution with others.
Print your name here.
Input: Ann Chris chris don don chris chris Bill
Output: don don chris chris chris Chris Bill Ann
NOTE:
Only one new class definition is allowed.
Unchecked operations are not allowed.
I certify that this program is my own work
and is not the work of others. I agree not
to share my solution with others.
Print your name here.
Input: ann Ann Ann Don Don don Chris Chris
Output: don ann Don Don Chris Chris Ann Ann
NOTE:
Only one new class definition is allowed.
Unchecked operations are not allowed.
I certify that this program is my own work
and is not the work of others. I agree not
to share my solution with others.
Print your name here.
Input: Ann ann Ann Bill don bill Chris Ann
Output: don bill ann Chris Bill Ann Ann Ann
//34567890123456789012345678901234567890123456789012345678
/*File Proj05 Co
--------------------------------------------------------*/
import java.util.*;
class Proj05{
static String[] names =
{"Don","don","Bill","bill","Ann","ann","Chris","chris"};
static String[] myArray = new String[8];
public static void main(String args[]){
if(args.length ==0){
System.out.println(
"You must provide a command-line argument");
System.exit(0);
}//end if
System.out.println();
System.out.println("NOTE:");
System.out.println("Only one new class definition is allowed.");
System.out.println("Unchecked operations are not allowed.");
System.out.println();
Proj05Runner runner = new Proj05Runner();
int seed = Integer.parseInt(args[0]);
Random generator = new Random(seed);
//Create and display the data for input to the class
// named Proj05Runner.
System.out.print("Input: ");
for(int cnt =0;cnt <8;cnt++){
int index =((byte)generator.nextInt())/16;
if(index <0){
index =-index;
}//end if
myArra

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_2

Step: 3

blur-text-image_3

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

Beginning C# 2005 Databases

Authors: Karli Watson

1st Edition

0470044063, 978-0470044063

More Books

Students also viewed these Databases questions

Question

Rational Choice decision making in Organizational behavior

Answered: 1 week ago