Question

The files must be called Proper coding conventions required the first letter of the class start...

The files must be called Proper coding conventions required the first letter of the class start with a capital letter and the first letter of each additional word start with a capital letter. Only submit the .java file needed to make the program run. Do not submit the .class file or any other file. 5% Style Components Include properly formatted prologue, comments, indenting, and other style elements as shown in Chapter 2 starting page 64 and Appendix 5 page 881-892. 5% Topics covered in chapter Topics with * are covered in this assignment. Ensure you use every item listed below in your completed assignment. *Array List class *Storing Primitives in Array List *Array List vs standard Array Linked List class List interface Queues, Stacks, and Array Deque class *Java Collections Basic Requirements This program is similar to Unit 1 except it uses array lists. Write a program that generates random number between 1 and 100, then allows you to search for matching values. Output is printed for a sorted and unsorted list. LiFiUnit2Ch10.java · Declare an array list to hold random numbers. · Get input for how many random numbers to use. · Using a “for loop”, add random numbers to the array list between 1 and 100. · Get input for value to be searched. · Using a “for-each loop” and a sequential search, search through the ar o Output “Unsorted list” and: o For each match found, output # found at location: # (see example) · Use java collections to sort the array list. · Using a “for-each loop” and a sequential search, search through the array list for the search term entered. o Output “Sorted list” and: o For each match found, output # found at location: # (see example) · Only print the headers and values if the search item is found. Print the total value of all random numbers added together after the search has complete. Sample output is provided below. Be sure to mimic it exactly except for the numbers entered.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

`Hey,

Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries

import java.util.*;

import java.util.Scanner;

public class Alist

{

public static void main(String []args)

{

//create an array list

ArrayList<Integer> col = new ArrayList<Integer>();

for(int m=0;m<1000;m++)

col.add((int) (Math.random()*100));

int flag=0;

//get element from user

Scanner rd = new Scanner(System.in);

for(int k=0;k<1000;k++)

System.out.println(col.get(k));

System.out.println("Enter the element to be searched:") ;

int x = rd.nextInt();

System.out.println("Before Sorting!!!") ;

for(int j=0;j<1000;j++)

{

if(x==col.get(j))

{

System.out.println(x+"found at location "+j);

flag=1;

}

}

if(flag==0)

{

System.out.println("No elements are matched" );

}

Collections.sort(col);

System.out.println("After Sorting!!!") ;

for(int l=0;l<1000;l++)

{

if(x==col.get(l))

{

System.out.println(x+"found at location "+l);

}

else

{

flag=1;

}

}

}

}

Answer Program code in java: import java.util.* import java.util.Scanner; public class Alist public static void main (StringCollections.sort (col); System.out.println (After Sorting!!!) for (int l-0 ;1<1000; 1++) if (xcol.get (1)) { System.out.priSample Output: Enter the element to be searched: 99 Before Sorting!!! 99found at location 61 99found at location 67 99found a

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
The files must be called Proper coding conventions required the first letter of the class start...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Using Arrays with Sorting and Searching Algorithms 1) This program has six required outputs and involves...

    Using Arrays with Sorting and Searching Algorithms 1) This program has six required outputs and involves searching and sorting an array of integers. Write a java application that initializes an array with the following numbers, in this order: 23, 17, 5, 90, 12, 44, 38, 84, 77, 3, 66, 55, 1, 19, 37, 88, 8, 97, 25, 50, 75, 61, and 49. Then display the unsorted values. This is required output #1 of 6 for this program. 2) Using a...

  • Write an object-oriented C++ program (i.e. a class and a main function to use it), using...

    Write an object-oriented C++ program (i.e. a class and a main function to use it), using pointer variables, that program that performs specific searching and sorting exercises of an array of integers. This program has six required outputs. Start by initializing an array with the following integers, in this order: 23, 17, 5, 90, 12, 44, 38, 84, 77, 3, 66, 55, 1, 19, 37, 88, 8, 97, 25, 50, 75, 61, and 49. Your array input may be hardcoded...

  • Write a menu based program implementing the following functions: (0) Write a function called displayMenu that...

    Write a menu based program implementing the following functions: (0) Write a function called displayMenu that does not take any parameters, but returns an integer representing your user's menu choice. Your program's main function should only comprise of the following: a do/while loop with the displayMenu function call inside the loop body switch/case, or if/else if/ ... for handling the calls of the functions based on the menu choice selected in displayMenu. the do/while loop should always continue as long...

  • Comparison of Sorting Algorithms You are required to implement all the sorting algorithms (Bubble, Selection, Insertion...

    Comparison of Sorting Algorithms You are required to implement all the sorting algorithms (Bubble, Selection, Insertion, Quick, Merge). Take help from lecture slides and welb . You will then create arrays of different sizes as instructed below, test each algorithm on each array and record the execution times of each individual algorithm on each array. . You will report these execution times in a table and then write a report explaining the execution times of the sorting algorithms according to...

  • cis 112 (java reqire to use JGRASP) Searching and Sorting Assignment This is a non-object oriented...

    cis 112 (java reqire to use JGRASP) Searching and Sorting Assignment This is a non-object oriented assignment. This assignment is due at the start of class on July 16, Create a program that populates and array with 100 random integers between 0 and 99. Then print out the array. Then prompt the user for a number, and do a sequential search on the unsorted array and return whether or not the number was in the array. Then sort the array...

  • This is JAVA language Create a .java class called MoreArrayFun.java with only a main method. This...

    This is JAVA language Create a .java class called MoreArrayFun.java with only a main method. This program will use the ArrayManager class. The final version of the program is described below, but initially use it to test your ArrayManager class as you write it. Complete the ArrayManager class as specified below: The class will have exactly two instance variables:  An array of integers  A count of the number of elements currently in the array The class will have...

  • Interfaces 1. What is inside an interface definition? What does a class do to an interface...

    Interfaces 1. What is inside an interface definition? What does a class do to an interface and what keyword is involved? How does a class do this to an interface (what should we find in the class)? Can an interface have a generic parameter? How do you instantiate an interface as an object? What methods can’t you use on an interface type? Abstract Data Types 2. What does an ADT define? Does an ADT specify programming language and/or data structures...

  • Homework 1- Merge Files: 1. Design a class named MergeFiles 1 Three file names are passed...

    Homework 1- Merge Files: 1. Design a class named MergeFiles 1 Three file names are passed as command-line arguments to MergeFiles as follows: java MergeFiles filel file2 mergedFile II. MergeFiles reads names stored in files file and file2 III. Merges the two list of names into a single list IV. Sorts that single list V. Ignores repetitions VI. Writes the sorted, free-of-repetitions list to a new file named mergedFile.txt VII. The names in all three files are stored as one...

  • Lab #7 CSE110 - Arizona State University Topics • Basic arrays Coding Guidelines • Give identifiers...

    Lab #7 CSE110 - Arizona State University Topics • Basic arrays Coding Guidelines • Give identifiers semantic meaning and make them easy to read (examples numStudents, grossPay, etc). • Keep identifiers to a reasonably short length. • Use upper case for constants. Use title case (first letter is upper case) for classes. Use lower case with uppercase word separators for all other identifiers (variables, methods, objects). • Use tabs or spaces to indent code within blocks (code surrounded by braces)....

  • Java Program Create a class to store an array of with enough space to store 10 integer values. Us...

    Java Program Create a class to store an array of with enough space to store 10 integer values. Using the principle of recursion, implement the following: *getSize : returns the size of the array. *get (i): returns the i-th element of the array. If the element does not exist, it throws a "NoSuchElementException” which is a subclass of Java class RunTimeException. *add (val): inserts value as the last element of the array. If necessary, double the size of the current...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT