Question

Design a modular program that accepts as input 20 numbers between 0 and 100 (including 0...

Design a modular program that accepts as input 20 numbers between 0 and 100 (including 0 and 100). The program should store the numbers in an array and then display the following information:

  • The lowest number in the array

  • The highest number in the array

  • The total of the numbers in the array

  • The average of the numbers in the array

Your program should consist of the following:

Module main. Accepts input of numbers and assigns them to an array. The array is traversed in order to find the highest number, lowest number, total and average of the numbers.

Module showStats. Displays the highest number, lowest number, total and average of the numbers.

Expected Output

The lowest number in the array is: 1

The highest number in the array is: 95

The total of the numbers in the array is: 811

The average of the numbers in the array is: 40.55

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

Note: Could you plz go through this code and let me know if u need any changes in this.Thank You
_________________


#include <iostream>
#include <iomanip>
#include <ctime>
#include <cstdlib>
using namespace std;
//Declaring the functions

void findMinMax(int &min,int &max,int &sum,double &avg,int A[],int SIZE);
void showStats(int min,int max,int sum,double avg);
int main()
{
//setting the precision to two decimal places
std::cout << std::setprecision(2) << std::fixed;

//Declaring constant
const int SIZE=20;
  
//Declaring variables
int A[SIZE],min,max;
  
/* Getting the inputs entered by the user
* and populate those values into array
*/
for(int i=0;i<SIZE;)
{
cout<<"Enter element#"<<(i+1)<<":";
cin>>A[i];
if(A[i]<0 || A[i]>100)
{
   cout<<"** Invalid.Must be between 0-100 **"<<endl;
   }
   else
   {
       i++;
   }
}
  
//calling the function
double avg=0;
int sum=0;
findMinMax(min,max,sum,avg,A,SIZE);
showStats(min,max,sum,avg);
  


return 0;
}
//function will calculate average of nos
double calAvg(int A[],int SIZE)
{
double sum=0,avg=0.0;
for(int i=0;i<SIZE;i++)
{
sum+=A[i];
}
avg=sum/SIZE;
return avg;
}
//Function find min and max nos in the array
void findMinMax(int &min,int &max,int &sum,double &avg,int A[],int SIZE)
{
min=A[0];
max=A[0];
for(int i=0;i<SIZE;i++)
{
if(min>A[i])
min=A[i];
if(max<A[i])
max=A[i];
sum+=A[i];
}
avg=sum/SIZE;
}
void showStats(int min,int max,int sum,double avg)
{
   //Dislaying the output
  
cout<<"The lowest number in the array is: "<<min<<endl;
cout<<"The highest number in the array is: "<<max<<endl;
cout<<"The total of the numbers in the array is: "<<sum<<endl;
cout<<"The average of the numbers in the array is: "<<avg<<endl;

   }

_____________________________

Output:

_______________Could you plz rate me well.Thank You

Add a comment
Know the answer?
Add Answer to:
Design a modular program that accepts as input 20 numbers between 0 and 100 (including 0...
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
  • Design a program that asks the user to enter a series of 20 numbers. The program...

    Design a program that asks the user to enter a series of 20 numbers. The program should store the numbers in the array and then display the following data: The lowest number in the array The highest number in the array The total of the number in the array The average of the numbers in the array PLEASE GIVE THE PSEUDOCODE AND CODE IN C PROGRAMMING

  • The Problem Design a program that lets the user enter the total rainfall for each of...

    The Problem Design a program that lets the user enter the total rainfall for each of 12 months into an array. The program should calculate and display the total rainfall for the year, the average monthly rainfall, the number of months above and below the average rainfall, and the highest rainfall for each quarter of the year. The Assignment Write a Java program that contains five method/functions as follows: main(). Calls the functions enterRain, rainStats, aboveBelow, and quarterlyRain. enterRain(). Uses...

  • Please write a Java program that does the following: Create an array of 100 integers. Store...

    Please write a Java program that does the following: Create an array of 100 integers. Store 100 random integers (between 1 and 100) in the array. Print out the elements of the array. Sort the array in ascending order. Print out the sorted array. Prompt the user to enter a number between 1 and 100. Search the array for that number and then display "Found" or "Not Found" message. Display each number from 1 to 100 and the number of...

  • 1. Write a program that randomly generates 10 whole numbers between 0 and 100 and stores...

    1. Write a program that randomly generates 10 whole numbers between 0 and 100 and stores them into an array. The program then calculates the average and displays the average and the numbers that are above the average. Use loops where needed. Must be stored in an array. Must be done using C++. 2. Write a program that reads 8 student scores, between 0 and 100, finds the best score, and then assigns grades based on the following scheme. Must...

  • Question 1: A. Design a program using a flowchart or pseudocode that accepts a person’s loyalty...

    Question 1: A. Design a program using a flowchart or pseudocode that accepts a person’s loyalty card number and amount spent in the store last month. Display the date only if the customer is a high spender – a person who spent more than $1000 in the store. B. A program that accepts customer info continuously until a sentinel value is entered and displays a list of high spenders.

  • CIS 22A C++ Project Exam Statistics Here is what your program will do: first it welcomes...

    CIS 22A C++ Project Exam Statistics Here is what your program will do: first it welcomes the user and displays the purpose of the program. It then prompts the user to enter the name of an input file (such as scores.txt). Assume the file contains the scores of the final exams; each score is preceded by a 5 characters student id. Create the input file: copy and paste the following data into a new text file named scores.txt DH232 89...

  • Program 2 <100 points>: Chips and Salsa (chipsSalsa.cpp) Write a program that lets a maker of...

    Program 2 <100 points>: Chips and Salsa (chipsSalsa.cpp) Write a program that lets a maker of chips and salsa keep track of sales for five different types of salsa: mild, medium, sweet, hot, and zesty. The program should use two parallel 5-element arrays: an array of strings that holds the five salsa names and an array of integers that holds the number of jars sold during the past month for each salsa type. The salsa names should be stored using...

  • Part I Short Answer (50 points) 1. Write a pseudocode declaration for a String array initialized...

    Part I Short Answer (50 points) 1. Write a pseudocode declaration for a String array initialized with the following strings: “Einstein”, “Newton”, “Copernicus”, and “Kepler”. 2. Assume names in an Integer array with 20 elements. Write a pseudocode algorithm a For Loop that displays each element of the array. 3. Assume the arrays numberArray1 and numberArray2 each have 100 elements. Write a pseudocode algorithm that copies the values in numberArray1 to numberArray2 . 4. Write a pseudocode algorithm for a...

  • Write a complete C++ program that reads students names and their test scores from an input...

    Write a complete C++ program that reads students names and their test scores from an input text file. The program should output each student’s name followed by the test scores and the relevant grade in an output text file. It should also find and display on screen the highest/lowest test score and the name of the students having the highest/lowest test score, average and variance of all test scores. Student data obtained from the input text file should be stored...

  • pseudocode and Python Repl.it :Recall that Programming Exercise 3 in Chapter 8 asked you to design...

    pseudocode and Python Repl.it :Recall that Programming Exercise 3 in Chapter 8 asked you to design a program that lets the user enter the total rainfall for each of 12 months into an array. The program should calculate and display the total rainfall for the year, the average monthly rainfall, and the months with the highest and lowest amounts. Enhance the program so it sorts the array in ascending order and displays the values it contains.

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