Question

1. prompt a user to enter10 numbers. 2..If the user enters anything other than number 10,...

1. prompt a user to enter10 numbers.

2..If the user enters anything other than number 10, remind her that only numbers are required that let her retry.

3. Do not allow the user to enter more than 10 or less than 10.

4. Display the 10 numbers back to the user at the end.

5.Calculate the following statistics from the 10 numbers entered.

Minimum

maximum

mean

range

variance

standard deviation

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

There are few points unclear in the question like

1. in point no 3 does it say we can only enter a value between 1 to 10 (both inclusive) or any 10 values.

2. In point 1 it is not specified that should the numbers be integers or any real values.

3. The language to use is unspecified

So I made some assumptions like we can enter only 10 real value numbers [1 to 10] (both inclusive) and the values can be any real number between the range. And the programming language used is C++. (if you want C just follow the comment in the code).

// If want in c compile with gcc <filename.c> -lm
#include<bits/stdc++.h> // If want in C replace it with #include<stdio.h> and #include<math.h> //(both)
using namespace std; //If want in C remove this line
int n=10;

double find_min(double a[]){ // To find the minimum element of the sequence
int i=1;
double min1 = a[0];
for (i=1;i<n;i++){
if(a[i]<min1){
min1 = a[i];
}
}
return min1;
}

double find_max(double a[]){ // To find the maximum element of the sequence
int i=1;
double max1 = a[0];
for (i=1;i<n;i++){
if(a[i]>max1){
max1 = a[i];
}
}
return max1;
}

double find_mean(double a[]){ //To calculate mean of the sequence
double mean =0;
int i=0;
for(i=0;i<n;i++){
mean+=a[i];
}
return mean/n;
}

double find_variance(double a[],double mean){ // To calculate Variance using mean of sequence
double variance = 0;
int i=0;
for(i=0;i<n;i++){
variance += ((a[i]-mean)*(a[i]-mean));
}

return variance/n;
}

double find_standard_deviation(double variance){ // To calculate standard deviation using variance of the sequence

return sqrt(variance);
}

int main(){ // Driver function

double a[n];
int i=0;

for (i=0;i<n;i++){ // Take input 10 numbers until all are in range and feasible
printf("Enter an %dth number: ",i+1);
scanf("%lf",&a[i]);

if(a[i]>n || a[i]<1){ // Prompt when wrong input
printf("Entered number is not in range retry\n");
i--;
}
}

double min1 = find_min(a);
double max1 = find_max(a);
double mean = find_mean(a);
double var = find_variance(a,mean);
double sd = find_standard_deviation(var);

// Print all the parameters
printf("Minimum element is : %lf\nMaximum element is : %lf\n",min1,max1);
printf("Range is from %lf to %lf\n",min1,max1);
printf("Mean is %lf : \n",mean);
printf("Variance is : %lf \nStandard Deviation is : %lf\n",var,sd);


return 0;
}

Here is my sample output :

Hope this helps

If any problem ask in the comment section

Add a comment
Know the answer?
Add Answer to:
1. prompt a user to enter10 numbers. 2..If the user enters anything other than number 10,...
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
  • write a program code that asks the user how many numbers they wish to find the...

    write a program code that asks the user how many numbers they wish to find the statistics of and then asks the user to enter those numbers. The program must then calculate and display the average variance and standard deviation of the numbers entered by the user. the program code must -ask three user how many numbers they wish to find the statistics of -ask the user to enter those numbers and store them in an array - use a...

  • 5.2 Write a program that repeatedly prompts a user for integer numbers until the user enters...

    5.2 Write a program that repeatedly prompts a user for integer numbers until the user enters 'done'. Once 'done' is entered, print out the largest and smallest of the numbers. If the user enters anything other than a valid number catch it with a try/except and put out an appropriate message and ignore the number. Enter 7, 2, bob, 10, and 4 and match the output below. ​ 1 largest = None 2 smallest = None 3 while True: 4...

  • 1. print mesage to user to prompt user to enter 10 numbers 2 have program accept...

    1. print mesage to user to prompt user to enter 10 numbers 2 have program accept 10 numbers from user and populate 10 occurrances of an array (use a loop to do this). 3. print message to user to advise user contents of array follows 4. have program display array contents (use loop to do this) end program comment in java please

  • Ask uFor Ex. "Prompt user to enter a number" = user enters 10, your program should...

    Ask uFor Ex. "Prompt user to enter a number" = user enters 10, your program should output 1, 2, 3, 4, 5, 6, 7, 8, 9, 10.ser to input a number, and then using a loop control statement (While, For, Do-While), output to the console the numbers beginning from 1, up to and including the number input by the user.

  • 1) Write a MATLAB script to prompt a user to input two numbers, then assess whether...

    1) Write a MATLAB script to prompt a user to input two numbers, then assess whether the two numbers are equal or not. If the two numbers are equal, display that they are equal in the Command Window. If they are not equal, display that they are not equal in the Command Window. 2) Write a MATLAB script that prompts the user to enter the day of the week using the input function. If the information the user enters is...

  • Prompt the user for two numbers, call them "x" and "y". "x" must be less than...

    Prompt the user for two numbers, call them "x" and "y". "x" must be less than "y" or reject the entry and stop the program. Otherwise, add up all of the numbers between "x" and "y" and display the result. For example: Enter x: 10 Enter y, larger than x: 20 Total + 10 = 10 Total + 11 = 21 Total + 12 = 33 Total + 13 = 46 Total + 14 = 60 Total + 15 =...

  • Write a program named ClassifyScores that classifies a series of scores entered by the user into...

    Write a program named ClassifyScores that classifies a series of scores entered by the user into ranges (0-9, 10-19, and so forth). The scores will be numbers between 0 and 100. Design and implement a program to prompt the user to enter each score separately. If the score is within the correct range, then increment the appropriate range If the score entered is greater than 100, display an error message, ignore the incorrect score, and prompt for the user to...

  • 1. Write a program to add positive numbers. Ask the user to enter numbers greater than...

    1. Write a program to add positive numbers. Ask the user to enter numbers greater than zero. If a 0, is entered stop requesting numbers and display the total. If a number is entered that is less than 0, display the message ‘Number must be greater than 0’, then ask for another number to be entered. Repeat until a number greater than 0 or 0 is entered. use math lab so I can copy the answers

  • Write a do-while loop that continues to prompt a user to enter a number less than...

    Write a do-while loop that continues to prompt a user to enter a number less than 100, until the entered number is actually less than 100. End each prompt with a newline. Ex: For the user input 123, 395, 25, the expected output is: Enter a number (<100): Enter a number (<100): Enter a number (<100): Your number < 100 is: 25 c++ #include using namespace std; int main() { int userInput = 0; do cout << "Your number <...

  • RandomGame.cpp (2pt) Write a program that asks the user to enter his/her name. Then begin a...

    RandomGame.cpp (2pt) Write a program that asks the user to enter his/her name. Then begin a do while loop that asks the user to enter a number between 1 and 10. Have the random number generator produce a number 1 and 10. Display the user’s name and both numbers to the screen. Compare the two numbers and report if the entered number is greater than, less than, or the same as the generated number. Ask the user if he/she’d like...

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
ADVERTISEMENT