1. Create List
2. Create Random integers
3. Search List
Write a program that gets random integers and populates a list, then searches the list
1. Write a program that creates an empty list
2. Populate the list with 100 random integers
3. After creating the list, print the length of elements in the list
4. Select a range of numbers as 10 – 20
5. Find out the number of times ‘15’ appears in the list and print it as
"The number of times 15 appears in the list is "
Since you have not mentioned the language of your preference, I am providing the code in Java.
CODE
import java.util.Arrays;
import java.util.Random;
public class Main {
public static void main(String[] args) {
int arr[] = new int[100];
Random rand = new Random();
for (int i=0; i<100; i++) {
arr[i] = rand.nextInt(11) + 10;
}
System.out.println("Size of list is: " + arr.length);
System.out.println("The list is: \n" + Arrays.toString(arr));
int count = 0;
for (int i=0; i<100; i++) {
if (arr[i] == 15) {
count ++;
}
}
System.out.println("The number of times 15 appears in the list is: " + count);
}
}
OUTPUT
Size of list is: 100
The list is:
[11, 20, 17, 16, 16, 13, 13, 14, 11, 18, 10, 12, 11, 17, 17, 15, 14, 12, 11, 20, 20, 16, 10, 12, 11, 13, 18, 10, 20, 14, 16, 20, 18, 15, 18, 15, 12, 11, 16, 13, 14, 13, 19, 14, 15, 15, 18, 16, 16, 11, 18, 12, 18, 14, 16, 18, 17, 13, 15, 19, 10, 19, 17, 14, 19, 10, 17, 13, 20, 20, 16, 18, 18, 20, 20, 13, 13, 14, 12, 15, 16, 11, 16, 17, 14, 20, 12, 16, 16, 14, 16, 20, 18, 18, 17, 18, 16, 18, 20, 11]
The number of times 15 appears in the list is: 7
1. Create List 2. Create Random integers 3. Search List Write a program that gets random...
c# prograaming language
1. write a program that generates 10,000 random integers in the
range of 0-9 and them in binary search tree.
2. use any sort algorithm (insertion, bubble, quick...) to
display a list of each of the integers and how many times they
appear.
3. at last, add ruction to the BinarySearchTree class that count
the number of edges in a tree.
Write a program that generates 10,000 random integers in the range of 0-9 and store them...
write in python Create a program that will ask the user for a list of integers, all on one line separated by a slash. construct a list named "adj_numbers" which contains the users input numbers after subtracting 2 from each number. then print the resulting list. the input statement and print statement are given to you in the starting code. a sample run of the program is as follows: Enter a list of integers, separated by slashes: 7/3/6/8 resulting list:...
Please write a Java program that does the following: Create an array of 100 integers. Store 100 random integers (between 1 and 100) in the array. Print out the elements of the array. Sort the array in ascending order. Print out the sorted array. Prompt the user to enter a number between 1 and 100. Search the array for that number and then display "Found" or "Not Found" message. Display each number from 1 to 100 and the number of...
Python: Create a function count_target_in_list that takes a list of integers and the target value then counts and returns the number of times the target value appears in the list. Write program in that uses get_int_list_from_user method to get a list of 10 numbers, then calls the count_target_list method to get the count then prints the number of times the target was found in the list. def get_int_list_from_user(): lst=[] y = int(input("Enter number of numbers")) for x in range(y): lst.append(int(input("Enter...
(+30) Provide a python program which will Populate an array(list) of size 25 with integers in the range -100 (negative 100) to +100 inclusive Display the array and its length (use the len function) Display the average of all the integers in the array Display the number of even integers (how many) Display the number of odd integers (how many) Display the number of integers > 0 (how many) Display the number of integers < 0 (how many) Display the...
A. Create a java program that generates 1000 random integers. Write the 1000 random integers to a file using the Formatter class. B. Create a second java program that opens the file with the 1000 integers using the Scanner class. Read in the integers and find and print out the largest, smallest and the average of all 1000 numbers. C. Repeat A from above but use the BufferedWriter class B. Repeat B from above but use the BufferedReader class.
Use Python 3
11a is using the binary search program that counts steps amend
the program so that a list of size 10000 is made - using unique
random numbers in the range 1 through 20000. Test how many steps to
find the number 9467.
Using your solution to Lab 11A, write a program that counts how many steps to find the number 9467 in a list of size 20000 (using unique random numbers in the range 1 through 321000)....
Write a java program: Create a method fillRandom() that accepts an array of int as input and populates it with random numbers in the range -999 to 1000 Explicitly store zero in index [0] and 900 in index [1]. (0 and 900 will be used as search keys) Create a method DisplayLastInts() that accepts an array of int as input and displays the last hundred elements to the screen in rows of 10 elements. Format the output so the 10...
CPT 180 Chapter 2 Assignment 3 Directions Using the following guidelines, create a python program. 1. Create a program named printRandomNumbers that gets input from the user and then produces a list of random numbers. 2. Import the random module 3. Add three comment lines at the top of the program that contain: a. Program Name b. Program Description c. Programmer's Name (You) 4. Prompt the user for the following: a. Number of random numbers required b. Lower limit of...
**C++ only, use standard library, no vectors Write a program to generate a list of 5000 random numbers between 1 and 10,000 stored in an array. Sorts: Print out the middle 50 numbers of the original list to show the results. Now sort the original numbers using bubble sort. Print out the number of swaps made. Now sort the original numbers using selection sort. Print out the number of swaps made. Now sort the original numbers using insertion sort. Print...