Answered step by step
Verified Expert Solution
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: ProjRunner.java uses unchecked or unsafe operations.
Note: Recompile with Xlint:unchecked for details.
Proj
Among other things, this assignment involves:
Working with Generics.
Working with collections.
PROGRAM SPECIFICATIONS
Write a program named Proj that uses the class definition contained in the file named Projjava to produce text output as described below.
Your challenge is to examine the code in the file named Projjava 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 ProjRunner.java.
The output text for any given run will depend on the input value provided as a commandline argument. The text shown below was produced by five consecutive runs of the program for input values of and respectively. I will test your program with a different undisclosed input value. You can test your program by running your version and my version sidebyside and comparing the results for any input value that you choose.
You must define a new class named ProjRunner. For this assignment, you must submit a single source code file named ProjRunner.java encapsulated in a zip file. It must contain the definition of a class named ProjRunner 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 Proj
Your program must not produce any output similar to the following:
Note: ProjRunner.java uses unchecked or unsafe operations.
Note: Recompile with Xlint:unchecked for details.
The purpose of Asg through Asg 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.
@SuppressWarningsunchecked
Do not include this annotation in your code.
Sample output for different commandline 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
File Proj Co
import java.util.;
class Proj
static String names
Don"don","Bill","bill","Ann","ann","Chris","chris";
static String myArray new String;
public static void mainString args
ifargslength
System.out.println
"You must provide a commandline argument";
System.exit;
end if
System.out.println;
System.out.printlnNOTE:;
System.out.printlnOnly one new class definition is allowed.";
System.out.printlnUnchecked operations are not allowed.";
System.out.println;
ProjRunner runner new ProjRunner;
int seed Integer.parseIntargs;
Random generator new Randomseed;
Create and display the data for input to the class
named ProjRunner.
System.out.printInput: ;
forint cnt ;cnt ;cnt
int index bytegeneratornextInt;
ifindex
index index;
end if
myArra
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started