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

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

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