This is about Java programming. I have uploaded the instructions and the source code is shown below. I would appreciate

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

This is about Java programming. I have uploaded the instructions and the source code is shown below. I would appreciate

Post by answerhappygod »

This is about Java programming. I have uploaded the instructions
and the source code is shown below. I would appreciate your help
here! Thank you!
This Is About Java Programming I Have Uploaded The Instructions And The Source Code Is Shown Below I Would Appreciate 1
This Is About Java Programming I Have Uploaded The Instructions And The Source Code Is Shown Below I Would Appreciate 1 (129.84 KiB) Viewed 48 times
Proj04 code: (must not be modified)
/*File Proj04
The purpose of this assignment is to assess the student's
ability to write a program dealing with sorting, arrays,
and collections.
***********************************************************/
// Student must not modify the code in this file.
import java.util.*;
class Proj04{
//Create an array containing names that will be used
// later.
static String[] names =
{"Don","don","Bill","bill","Ann","ann","Chris","chris"};
//Create an empty array that will be populated with
// randomly selected names and used later.
static Object[] myArray = new String[8];
//Begin the main method
public static void main(String args[]){
//Instantiate a new object of the student's class
// and display the certification.
Proj04Runner runner = new Proj04Runner();
//Create a pseudo-random number generator
Random generator = null;
if(args.length != 0){
//User entered a command-line argument. Use it
// for the seed.
System.out.println("seed = " + args[0] );
generator = new Random(Long.parseLong(args[0]));
}else{
//User did not enter a command-line argument.
// Get a seed based on date and time.
long seed = new Date().getTime();
System.out.println("seed = " + seed);
generator = new Random(new Date().getTime());
};
//Create and display the data for input to the class
// named Proj04Runner.
System.out.print("Input: ");
for(int cnt = 0;cnt < myArray.length;cnt++){
int index = ((byte)generator.nextInt())/16;
if(index < 0){
index = -index;
}//end if
if(index >= 8){
index = 7;
}//end if
myArray[cnt] = names[index];
System.out.print(myArray[cnt] + " ");
}//end for loop
System.out.println();//new line
//Process the data, get, and display intermediate
// results.
myArray = runner.runA(myArray);
System.out.print("Intermediate Results: ");
for(int cnt = 0; cnt
System.out.print(myArray[cnt] + " ");
}//end for loop
System.out.println();
//Finish processing the data, get, and display
// final results.
Collection collection = runner.runB();
System.out.print("Final Results: ");
Iterator iter = collection.iterator();
while(iter.hasNext()){
System.out.print(iter.next() + " ");
}//end while loop
System.out.println();
}//end main()
//----------------------------------------------------//
}//end class Proj04
Some tip given:
In case you have difficulty completing this assignment, here is
a strategy that may help you.
See the assignment specifications in general and the samples for
different seed values near the bottom.
For the case of seed = 1,
Input: chris Bill Chris Chris Don don don Bill
Intermediate Results: Bill chris Don
Going from left to right, identify the strings from the Input
that are contained in the Intermediate Results. This will give you
the following strings:
chris Bill Don
However, they are not in the correct order for the Intermediate
Results. Compare this list with the Intermediate Results and
develop a procedure that will cause them to match. You may want to
consider implementing the protocol in a TreeSet object. Return the
Intermediate results. Also save this list for use later to produce
the Final Results.
Compare this list with the Final Results. Note that they contain
the same strings but not necessarily in the correct order. Develop
a procedure that will cause them to match. Return the final
results.
Note that the use of the word "list" above does not imply any
particular data structure.
Check your program against the assignment specifications for
seed values of 1 through 6 to confirm that your algorithm works for
multiple seed values and not just for a single seed value.
############################
Here is the skeleton of the runB method from my version of the
program. Note that the indentation was lost in the construction of
this announcement.
//=======================================================

//Finish processing and return the data as type
// Collection.
Collection runB(){

//Create a final TreeSet object that imposes the
// reverse of the natural ordering on a collection
// of objects that implement the Comparable
// interface. The reverse of the natural ordering
// means that this is a case sensitive reverse sort.
myTreeSet = ...;
...
...
return myTreeSet;

}//end runB
Among other things, the purpose of this assignment is to assess the student's ability to write a program dealing with sorting, arrays, and collections. seed = 3 Input: Ann Chris chris don don chris chris Bill Intermediate Results: Ann Bill Chris don Final Results: don Chris Bill Ann PROGRAM SPECIFICATIONS Beginning with the file that you downloaded named Proj04.java, create a new file named Proj04Runner.java to meet the specifications given below. seed = 4 Input: ann Ann Ann Don Don don Chris Chris Intermediate Results: ann Chris Don Final Results: ann Don Chris Note that you must not modify the code in the file named Proj04.java. Be sure to display your name in the output as indicated. seed = 5 Input: Ann ann Ann Bill don bill Chris Ann Intermediate Results: Ann Bill Chris don Final Results: don Chris Bill Ann When you place both files in the same folder, compile them both, and run the file named Proj04.java with a command-line argument of 6, the program must display the text shown below on the command line screen. Output: seed = 6 Input: chris chris Chris Chris Don ann don Ann Intermediate Results: ann chris Don Final Results: chris ann Don Press any key to continue 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. seed = 6 Input: chris chris Chris Chris Don ann don Ann Intermediate Results: ann chris Don Final Results: chris ann Don When you place both files in the same folder, compile them both, and run the file named Proj04.java without a command-line argument, the program must display text that is similar to, but not necessarily the same as the text shown below on the command line screen. In this case, the input names are based on a random number generator that will change from one run to the next because the seed is based on the date and time. Your output text must match my output text for a command-line argument of any numeric value that you choose. Run your program and my program side by side with different command-line- arguments to confirm that they match before submitting your program. For example, the following text shows the output text created by running my program six times in succession for command-line argument values of 1 through 6 respectively. (Note that I deleted the certification text from each output to conserve space.) 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. seed = 1587598279742 Input: Ann don Ann Ann Ann don Bill Bill Intermediate Results: Ann Bill don Final Results: don Bill Ann Outputs samples: seed = 1 Input: chris Bill Chris Chris Don don don Bill Intermediate Results: Bill chris Don Final Results: chris Don Bill seed = 2 Input: bill Don chris don don bill ann Ann Intermediate Results: ann bill chris Don Final Results: chris bill ann Don
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply