Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Your challenge is to examine the code in the file named Proj 0 5 . java along with the output text shown below to deduce
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:argument of
NOTE:
Only one new class definition is allowed.
Unchecked operations are not allowed.
Input: chris Bill Chris Chris Don don don Bill
Output: don don chris Don Chris Chris Bill Bill
argument of
NOTE:
Only one new class definition is allowed.
Unchecked operations are not allowed.
Input: bill Don chris don don bill ann Ann
Output: don don chris bill bill ann Don Ann
argument of
NOTE:
Only one new class definition is allowed.
Unchecked operations are not allowed.
Input: Ann Chris chris don don chris chris Bill
Output: don don chris chris chris Chris Bill Ann
argument of
NOTE:
Only one new class definition is allowed.
Unchecked operations are not allowed.
Input: ann Ann Ann Don Don don Chris Chris
Output: don ann Don Don Chris Chris Ann Ann
argument of
NOTE:
Only one new class definition is allowed.
Unchecked operations are not allowed.
Input: Ann ann Ann Bill don bill Chris Ann
Output: don bill ann Chris Bill Ann Ann Ann Here are the contens of Proj to help: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
myArraycnt namesindex;
System.out.printmyArraycnt;
end for loop
System.out.println;new line
Process the data and display the results.
Collection collection runner.getCollectionmyArray;
System.out.printOutput: ;
Iterator iter collection.iterator;
whileiterhasNext
System.out.printiternext;
end while loop
System.out.println;
end main
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