A group of 30 people have gone apple picking at Battleview Orchards. Each person has picked a number of apples. Your C++ program will create a file containing 30 random numbers with values between 2 and 75. These numbers represent the number of apples a person picked. You are then to determine a. How many people picked 10 or fewer apples. b. How many people picked between 50 and 75 apples c. The average number of apples picked d. For those who picked between 2 and 5 apples change that number to 0 (they ate their apples) and print the new array contents. The functions you must write: a. Write a function to create an input data file of 30 random numbers with values between 2 and 75. You can do this by writing a short C++ loop in your function. As you create the numbers print them out (on the screen), 2 spaces between each number and print the 30 random numbers the file, then close the file and (open it as input in main) b. Passing the array to a count function, determine how many of the people picked 10 or fewer apples The function returns the count to main. Main prints the result. c. Pass the array to another count function to determine how many of the numbers are between 50 and 75 apples, The function returns the count to main. Main prints the result. d: Pass the array to a function to compute the average number of apples picked, The function returns the average to main. Main will print the result. e. Pass the array to a function and change all apple numbers that are between 2 and 5 to 0¸ Print the revised array in main.
A group of 30 people have gone apple picking at Battleview Orchards. Each person has picked a number of apples.
Your C++ program will create a file containing 30 random numbers with values between 2 and 75. These numbers represent the number of apples a person picked. You are then to determine
a. How many people picked 10 or fewer apples.
b. How many people picked between 50 and 75 apples
c. The average number of apples picked
d. For those who picked between 2 and 5 apples change that number to 0 (they ate their apples) and print the new array contents.
The functions you must write:
a. Write a function to create an input data file of 30 random numbers with values between 2 and 75. You can do this by writing a short C++ loop in your function. As you create the numbers print them out (on the screen), 2 spaces between each number and print the 30 random numbers the file, then close the file and (open it as input in main)
b. Passing the array to a count function, determine how many of the people picked 10 or fewer apples The function returns the count to main. Main prints the result.
c. Pass the array to another count function to determine how many of the numbers are between 50 and 75 apples, The function returns the count to main. Main prints the result.
d: Pass the array to a function to compute the average number of apples picked, The function returns the average to main. Main will print the result.
e. Pass the array to a function and change all apple numbers that are between 2 and 5 to 0¸ Print the revised array in main.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images