Generate a random integer

Assignment Help Business Economics
Reference no: EM131357918

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: EM131357918

Questions Cloud

Make a sketch of the deformed shape of a beam : Make a sketch (not to scale) of the deformed shape of a beam subject to a positive bending moment Mx. Make sure your drawing shows the thickness of the beam; i.e., do not idealize the beam by a line.
Calculate the expected number of automobile accidents : The number of auto accidents in Athens, Ohio, is related to the regional number of registered automobiles in thousands (X1), alcoholic beverage sales in $10,000s (X2), and rainfall in inches (X3). Calculate the expected number of automobile accidents..
Compute the extensional coupling and bending stiffness : Compute the extensional [A], coupling [B], and bending stiffness [D] matrices of a bimetallic (copper and aluminum) strip with each lamina 2 mm thick.
Construct a vector x that contains integers and real numbers : Construct a vector x that contains integers, real numbers, chains of characters, and several NA missing values. Test for the positions of the missing values using the is.na function. Produce the subvector where all missing values have been elimina..
Generate a random integer : PROGRAM A: This program should use a main function and another function named makelist as follows:
Write a research paper about user interface : Write a research paper about USER INTERFACE. what you plan to accomplish and why, include an overview of the situation or organization. Cite and support all content appropriately.
Communicate with your customers : One difficulty of moving a small business from a traditional retail store to an online store is channel complications. In many cases, everything has to be reconsidered. For example, how will you communicate with your customers? How will they find ..
What is the power rating of each of the diodes : Assuming that the power rating of a breakdown diode is established at about twice the specified zener current (IZT),what is the power rating of each of the diodes described above?
Compute the matrices for the given laminates : Compute the [A], [B], [D], and [H] matrices for the following laminates. All laminae are 1.0 mm thick. Comment on the coupling of the constitutive equations for each case.

Reviews

Write a Review

Business Economics Questions & Answers

  Economics assignment

This document contains various important questions and their appropriate answers in the subject field of Economics.

  Demand and supply curves

Economics is the study of the principles governing the allocation of scarce means among competing ends when the objective of the allocation is to maximize the attainment of the ends.

  Long-run perfectly competitive equilibrium for the firm

Evaluate Government intervene and correct this situation?(a) Explain the concept of a concentration ratio. A rise in the price of magarine Explain the impact of external costs and external benefits on resource allocation long-run perfectly c..

  Supply and demand diagrams

Explain each of the following using supply and demand diagrams,  With the use of a graph, explain how these two programs affect cigarette consumption and the price of cigarettes.

  Case study: fisher-price toys

The case study of the Fisher-Price Toys, Inc., a popular case in basic economics and management from the prestigious Harvard Business School.

  Draw the production possibility curve

Draw the production possibility curve and a. Define consumer surplus and producer surplus.

  Tax revenue

The Australian government administers two programs that affect the market for cigarettes

  Maximize total welfare

How many tickets to sell to maximize total welfare.

  Difference between the cv and the ev

The change in consumer surplus (?CS) is not "theoretically" justifiable like the CV and EV but it continues to be the most widely used measure of consumer welfare change. Explain how this can be reconciled

  Depict von neumann-morgenstern utility index u in a diagram

Depict the von Neumann-Morgenstern utility index u in a diagram

  What is the market solution

What is the market solution (market price and quantity) and What is the total surplus of the society under the market solution

  Calculate gross national product and net national product

Calculate gross national product and net national product

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