Number of elements equal to the random integer argument

Assignment Help Basic Computer Science
Reference no: EM131368452

PROGRAM A: This program should use a main function and another function named makelist as follows:

  • In main, generate a random integer that is greater than 5 and less than 13.
  • Print this number on its own line.
  • Call the makelist function with the random integer as sole argument.
  • Inside the makelist function:
    • Make an empty list.
    • Use a loop to append to the list a number of elements equal to the random integer argument. All new list elements must be random integers ranging from 1 to 100, inclusive. Duplicates are okay.
    • Return the list to main.
  • Back in main, catch the returned list and sort it.
  • Finally, use a for loop to display the sorted list elements, all on one line, separated by single spaces.

SAMPLE OUTPUT

List size will be 7

Here is the sorted list:

8 28 35 41 51 62 72

ANOTHER SAMPLE OUTPUT

List size will be 10

Here is the sorted list:

3 3 9 20 36 43 48 50 81 93

PROGRAM B: Use the text file named scores.txt (supplied). It contains a number of integer test scores, one per line. Your program should use a main function and another function named showscores as follows:

  • In main, create an empty list.
  • Open the file named scores.txt.
  • Use awhile loop that can detect the end of fileto read the scores, and add them to the list.
  • Close the file.
  • Call the showscores function with the list of scores as sole argument.
  • Inside the showscores function:
    • Process the list of scores.
    • NOTE: your instructor will use a modified version of scores.txt with different scores and a different number of scores. Your code should be capable of handling this.
    • Print out the average score accurate to two decimal places.

Reference no: EM131368452

Questions Cloud

Research and explain the pros and cons of the debate : The debate over the legalization of marijuana in the United States has been raging for over a century, with both sides having clear points of view. Research and explain the pros and cons of this debate.
Case analysis – application of analytical tools : Assessment Task 1: Case Analysis – Application of analytical tools, Goal: For you to demonstrate cognitive, technical and creative skills to investigate, analyse and synthesise complex information, problems, concepts and theories and to apply establi..
Write an essay that critiques the given statement : Write an essay that critiques the following statement.- It may include a standard form of the argument, it may identify and address a fallacy, and it may critique a theory. All methods are open for utilization in the critique.
Define the disease and describe all relevant symptoms : Describe all relevant symptoms.List all known causes of the disorder; include any environmental factors that may be involved; list and medications and/or genetics that may cause the disease.Identify any known risk factors; include any age groups, ..
Number of elements equal to the random integer argument : Use a loop to append to the list a number of elements equal to the random integer argument. All new list elements must be random integers ranging from 1 to 100, inclusive. Duplicates are okay.
Discuss what influences ethical decision making : Ethical decision making is a necessary part of doing business. Discuss what influences ethical decision making. What are some practical steps that managers can take to improve ethical decision making?
What is the compound average annual rate of return : Create a Line chart showing the stock price from May 2006 to May 2011. Make sure to title the chart and label the axes.
Write the given paper assignment : Select a contracting subject pertaining to the FAR Sections covered in this class- Research individually the selected topic.
International human resource management : You are the HR Manager of an Australian based airline that operates both domestic and international services and has its headquarters in Melbourne. Your organisation has decided to recruit a manager who has extensive experience in the airline industr..

Reviews

Write a Review

Basic Computer Science Questions & Answers

  How breadth-first ranking of vertices of g can be performed

Show how the breadth-first ranking of vertices of G can be performed on a p-process mesh.

  Performs encryption

Performs encryption

  Explain how views can be used to improve data security

Describe how views are used to provide an alias for tables. Why is this useful?

  How does this change in the grass mechanism affect

Eventually the grass will hit a limit of physical space and be adversely affected by overcrowding and competition for water, nutrients, and sunlight. How would you model that? How does this change in the grass mechanism affect the behavior of the ..

  Needleman-wunsch algorithm

Using Perl or Python programming languages, implement the Needleman-Wunsch algorithm to find the optimal global alignment between two sequences. The program should ask the user to input the two sequences first

  Layered model vs monolithic model of data communication

Prepare a Powerpoint Presentation, Discussing our impressions about the major implications/issues involved in adopting a layered model

  What is the chance that exactly one request is made

What is the chance that The bus is idle (0 requests), Exactly one request is made and More than one request is made.

  What is the purpose of the finally clause

What happens when an exception is thrown, the code of a finally clause executes, and that code throws an exception of a different kind than the original one? Which one is caught by a surrounding catch clause? Write a sample program to try it out.

  Mission and values of better world books

What are the mission and values of Better World Books? Critically evaluate their usefulness to the company's management in formulating strategy.

  Which has the following initial set of process credentials

which has the following initial set of process credentials:

  Determines whether a graph contains a cycle

write pseudo code for an algorithm that determines whether a graph contains a cycle.

  Break up components of a string

I'm having a lot of trouble with a concept in java. How do you break up components of a string (a sentence) and check that the number of letters is greater than or equal to a certain length?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd