Question

Write a program that creates a list of 20 integers (between 1 and 40) using a random number generator function. Write a function that returns the index (position) of the third largest element from the...

Write a program that creates a list of 20 integers (between 1 and 40) using a random number generator function. Write a function that returns the index (position) of the third largest element from the list of integers. If there are more than one third largest number, return the index of the first occurrence of that number.
Eg: Assume that your main function has created the following list of integers generated from the random number function.
[12, 30, 28, 4, 17, 21, 5, 3, 35, 33, 23, 25, 21, 14, 14, 33, 16, 38, 13, 29]
Expected output:
List of integers:
[12, 30, 28, 4, 17, 21, 5, 3, 35, 33, 23, 25, 21, 14, 14, 33, 16, 38, 13, 29]
Third largest number: 33
Index (position) of third largest number: 10

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

Main - JCreator File Edit View Project Build Run Tools Configure Window Help Sort,jav Main.javaX public class Main ( atatic vMain - JCreator File Edit View Project Build Run Tools Configure Window Help Sort,jav Main.javaX else if (arrayi ecmax) thirdMain - JCreator File Edit View Project Build Run Tools Configure Window Help Sortjav Main.java*x public class Main ( atatic vMain - JCreator File Edit View Project Build Run Tools Configure Window Help Sortjav Main.java*x else if (arrayi ecmax) thirdMain - JCreator File Edit View Project Build Run Tools Configure Window Help Sort,jav Main.javaX else if (arrayi ecmax) third

Add a comment
Know the answer?
Add Answer to:
Write a program that creates a list of 20 integers (between 1 and 40) using a random number generator function. Write a function that returns the index (position) of the third largest element from the...
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
  • Write a program that creates a list of 20 integers (between 1 and 40) using a...

    Write a program that creates a list of 20 integers (between 1 and 40) using a random number generator function. Write a function that returns the index (position) of the third largest element from the list of integers. If there are more than one third largest number, return the index of the first occurrence of that number. Eg: Assume that your main function has created the following list of integers generated from the random number function. [12, 30, 28, 4,...

  • Write a Python program that tests the function main and the functions discussed in parts a...

    Write a Python program that tests the function main and the functions discussed in parts a through g. Create the following lists: inStock - 2D list (row size:10, column size:4) alpha - 1D list with 20 elements. beta - 1D list with 20 elements. gamma = [11, 13, 15, 17] delta = [3, 5, 2, 6, 10, 9, 7, 11, 1, 8] a. Write the definition of the function setZero that initializes any one-dimensional list to 0 (alpha and beta)....

  • FindGCF.py 1 #The Greatest Common Factor (GCF) of two numbers is the 2 #largest number that...

    FindGCF.py 1 #The Greatest Common Factor (GCF) of two numbers is the 2 #largest number that divides evenly into those two 3 #numbers. For example, the Greatest Common Factor of 48 4 #and 18 is 6. 6 is the largest number that divides evenly 5 #into 48 (48 / 6 = 8) and 18 (18 / 6 = 3). 6 # 7 #Write a function called find gcf. find gcf should have 8 #two parameters, both integers. find_gcf should return...

  • Records from a random sample of 40 couples applying for a marriage license in Denver yielded...

    Records from a random sample of 40 couples applying for a marriage license in Denver yielded the following ages for the 40 women in years: 19 20 20 20 21 21 22 22 23 23 24 24 24 25 25 25 25 25 26 28 29 29 29 29 30 30 30 31 31 31 31 32 33 35 35 36 38 40 43 46. Construct a 99% confidence interval for the mean of the age of women getting married...

  • A soft drink manufacturer uses fire agents to handle premium distribution for is various products. The marketing director desired to study the timeliness with which the premiums are distributed. Twent...

    A soft drink manufacturer uses fire agents to handle premium distribution for is various products. The marketing director desired to study the timeliness with which the premiums are distributed. Twenty transactions for each agent were selected at random and the time lapse (in days) for handling each transaction was determined. The results follow: Agent 1 Agent 2 Agent 3 Agent 4 Agent 5 24 18 10 15 33 24 20 11 13 22 29 20 8 18 28 20 24...

  • Assembly Language Programming Assignment program must be in: MASM assembly language / x86 architecture / irvine...

    Assembly Language Programming Assignment program must be in: MASM assembly language / x86 architecture / irvine library procedures Objectives: 1. using register indirect addressing 2. passing parameters 3. generating “random” numbers 4. working with arrays Description: Write and test a MASM program to perform the following tasks: 1. Introduce the program. 2. Generate ARRAYSIZE random integers in the range [LO = 10 .. HI = 29], storing them in consecutive elements of an array. ARRAYSIZE should be set to 200....

  • Therefore, for this program you will read the data in the file named weatherdata_2.txt into arrays...

    Therefore, for this program you will read the data in the file named weatherdata_2.txt into arrays for the wind speed and for the temperature. You will then use the stored data to calculate and output the average wind speed and the average temperature. Create a constant with a value of 30 and use that to declare and loop through your arrays and as a divisor to produce your averages. Here is the data file (below). 1. 14 25 2. 12...

  • Write the Code in C program. Create a random password generator that contains a user-specified number...

    Write the Code in C program. Create a random password generator that contains a user-specified number of characters. Your program should prompt the user for the desired length of the password. Length of password: To create your password, use the random number generator in the stdlib.h C library. To generate random numbers, you will need the srand() and rand() functions. srand(seed) is used to "seed" the random number generator with the given integer, seed. Prompt the user for the seed...

  • 3.25 The file AccountingPartners contains the number of part-ners in a cohort of rising accounting firms...

    3.25 The file AccountingPartners contains the number of part-ners in a cohort of rising accounting firms that have been tagged as "firms to watch." The firms have the following numbers of partners:17 23 19 23 18 17 23 16 34 10 14 30 14 33 26 17 19 2220 27 33 25 12 26 13 30 13 13 33 21 17 12 10 14 12 a. Compute the first quartile 1012, the third quartile 1032, and the interquartile range. b....

  • JQuery- need help with the option to Edit the items on To-Do list program...either an option...

    JQuery- need help with the option to Edit the items on To-Do list program...either an option for edit button or double clicking the item will enable user to edit the list   <div id="container"> <hl>To-Do List<i class=" fas fa-plus"></i></hl> <input type ="text" ame' placeholder="Add Items To Do" id-'nan kul id-"display" <li><span>i class="fas fa-trash"></i></span> Build An Todo List</li> <li><span><i class="fas fa-trash"></i></span>Build Color Game</li> <li><span><i class="fas fa-trash"></i></span> Build Calculator</li> </ul> <button onclick="save ()">save< /button> </div> ("ul").on("click", "li",function () 5 $(this).toggleclass ("completed"); 6 7...

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