Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Business Management Expert

Part 1:  Create a new project Lab5Part1. This part is going to be based on Lab4Part1 anduse two one-dimensional arrays with data read in from a file.These arrays will be the TopNumber and TopName arrays from Lab4Part1.  However, the data that the arrays read from will be unordered from a new data file, SciFiFantasyYearMix.txt.

You will read in the data from the file just as before.  Next print the unordered data from the arrays.  Use the same menu printing format as from Lab4Part1, i.e. all the numbers and titles in a table.   Sort the data in the arrays using a bubble sort method then print the array data again for the user to choose from.  Let the user choose and use linear search to print the user's choice and the associated name.

You must write a method that uses the bubble sort algorithm to sort the numeric array.  As you sort the numeric array, you must also sort the names array at the same time.  Your bubble sort method should take in the TopNumber and TopNames arrays and the MAXITEMS value as the input parameters. Save this program as Lab5Part1.java and put two test runs in your answers file.

Part 2: Create a new project Lab5Part2.  Copy the code from Lab5Part1 into the project.  Change the arrays TopName and TopNumber into ArrayLists instead of arrays.  Instead of calling your bubble sort array, use the built-in sort mechanism to sort TopNumber.  Use the input file SciFiFantasySearchable2.txt to test with.  Then test with the file CandySearchable.txt . Save this program as Lab5Part2.java and put the two test runs in your answers file.

2.a) In your Lab5Part2 file, can you sort the TopName array with the TopNumber array?  Why or why not?  Put your answer in your answer file.

Part 3: Create a new project Lab5Part3.  Copy Lab5Part1 into the project.NOTE: use arrays not ArrayLists.  Create a new bubble sorting method that sorts the name strings instead of the numbers.  Follow the same steps as Lab5Part1 but call the string sorting method instead of the number sorting method.  Use the same input files as Lab5Part2 to test.  Save this program as Lab5Part3.java and put two test runs in your answers file]

Part 4: Create a new project Lab5Part4.  Read in the numeric data from SciFiFantasySearchables2.txt  Ask the user to pick a value between 0 and the maximum numeric value from the file and have your program determine if it is in the array.

4.a) Create a new project Lab5Part4a from Lab5Part4.   Write a method that takes in the array and the user input and determines if the value is in the array by using linear search.  If it is the array, return the index of the array location.  If it is not in the array, return -1.  Print the location of the user's input value in the unsorted array.  Next print the unsorted array values out in a table with 40 rows of 5 values each.  Use formatted output to make this table.  Call the bubble sort method from Lab5Part1 to sort the array and print the values again.  Call the linear search method again to determine where the user's value is in the sorted array and output the location.

4.b) Create a new project Lab5Part4b from Lab5Part4.   Write a method that takes in the array and the user input and determines if the value is in the array by using binary search.  If it is the array, return the index of the array location.  If it is not in the array, return -1.  Print the location of the user's input value in the unsorted array. Next print the unsorted array values out in a table with 40 rows of 5 values each.  Use formatted output to make this table.  Call the bubble sort method from Lab5Part1 to sort the array and print the values again.  Call the binary search method again to determine where the user's value is in the sorted array and output the location.

4.c) Did linear search find the value in the unsorted array and the sorted array?  Why or why not?  Put your answer in your answers file.

4.d) Did binary search find the value in the unsorted array and the sorted array?  Why or why not? Put your answer in your answers file.

Extra credit tasks if desired.  All extra credit is optional:

XC1)  Measure time for the sorting methods in 4a and 4b.  Create new project Lab5XC1 that creates two intArrayLists of size 5000 that get the same unsorted values stored in them.  Use the first array and call a modified bubble sort method for ArrayLists to sort it and use the second array to call the built-in quick sort method for ArrayLists. 

For each method, use the Java Instant class to find the instant before the method is called, then another Instant when the method returns to the caller, then subtract the two and print the value to give a measurement of the run time of the method.

Put your program in a loop that runs the entire process 5 times, i.e. creates 5 unique unsorted arrays.  Capture the run times of the methods in a 2D array and after the 5 iterations are done, print a table of the times.  Make sure the label the columns and rows of your output table.

XC2)  Write a method that implements Quicksort withthe Hoare partition scheme for int arrays.  Replace the bubble sort method in Lab5Part4b.java with this quicksort method and test as described.

XC3) Write a program that reads in and stores the data from SciFiFantasySearchable2.txt and then prints the table of unsorted data to an output file.  Next, sort the array by the numeric data and print this sorted array to the output file.  Finally, sort the array by the name data and print this sorted array to the output file.  The output file should end with all three tables of the data in the output file.  NOTE: There are many ways to create and write to output files in Java.  One of the simplest ways to do this is to connect a File , ex.out.txt, to a PrintStream, ex. outFile,  and then set up this PrintStream as the designated output stream with the command System.setOut(outFile);

XC4)Write a program to create an integer array or ArrayListof size 2000 and fill it with random numbers between 0 and 10000 using the Random class or the Math.Random class to generate the values.  Ask the user to pick a value between 0 and 10000 and your program will determine if it is in the array.  Use linear search first, then sort the array with Java's qsort and search again with binary search.

Business Management, Management Studies

  • Category:- Business Management
  • Reference No.:- M93051980
  • Price:- $20

Priced at Now at $20, Verified Solution

Have any Question?


Related Questions in Business Management

Analyze the time complexity of the following ternary search

Analyze the time complexity of the following ternary search algorithm: identify two points that subdivide a sorted array into three parts. If the given number is equal to one of these two points, we are done. Otherwise, ...

Explain the contributions that teams make and how managers

Explain the contributions that teams make and how managers can help teams be more effective.

You are a contracts administrator for a contractor one of

You are a Contracts Administrator for a Contractor. One of your engineering managers found an inconsistency in the specification on a FFP solicitation (i.e., pre-award). He said the worst case could be a $3M loss for def ...

Can you please direct me on how i should go about

Can you please direct me on how I should go about describing an interview by providing 3 structured behavioral questions? Choose a job that you are interested in. You may relate it to your term project by choosing a movi ...

Is this asking for the factors that affect planninganalyze

Is this asking for the factors that affect planning? Analyze factors that define and shape management (such as the economy, customer needs and wants, and innovation). What is the relative influence of these factors (whic ...

How to develop a java script function to get first name and

How to Develop a java script function to get First name and Last name from users and display the following massage in a window alert box. Hello First name, How are you? For example if the user enters Sara as first name, ...

Do you agree that the pace of technology change is

Do you agree that the pace of technology change is relentless? What do you think that means to most business professionals? To most organizations?

Bull draft a one-two sentence personal definition of

• Draft a one-two sentence personal definition of leadership. Base your definition on what you have encountered, as well as on what you have already know about leadership. • Discuss the statements: "Leadership is everybo ...

A description of how each of the two management styles

A description of how each of the two management styles selected distinctively create organizational cultures. Describe the strengths and weaknesses of the two styles. Explain how these differences could align or be disso ...

Some residents of the village of taugswater have proposed

Some residents of the village of Taugswater have proposed purchasing logging permits relating to a nearby wilderness area. The majority of residents agree that the purchase of permits, to be set aside and not used, is th ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As