Question

Write a program that takes as input five numbers a
0 0
Add a comment Improve this question Transcribed image text
Answer #1

// C++ code to determine mean and standard deviation

#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <stdlib.h>   
#include <math.h>

using namespace std;


int main()
{
double X1,X2,X3,X4,X5;
double mean, standard_deviation;

cout << "Enter first number: ";
cin >> X1;
cout << "Enter second number: ";
cin >> X2;
cout << "Enter third number: ";
cin >> X3;
cout << "Enter fourth number: ";
cin >> X4;
cout << "Enter fifth number: ";
cin >> X5;

mean = (X1+X2+X3+X4+X5)/5;

standard_deviation = sqrt((pow((X1-mean),2) + pow((X2-mean),2) + pow((X3-mean),2) + pow((X4-mean),2) + pow((X5-mean),2) )/5);

cout << "\nMean: " << mean << endl;
cout << "Standard Deviation: " << standard_deviation << endl;

return 0;
}

/*
output:

Enter first number: .5
Enter second number: 2.3
Enter third number: 4.2
Enter fourth number: 1.4
Enter fifth number: 6.4

Mean: 2.96
Standard Deviation: 2.11149

*/

Add a comment
Know the answer?
Add Answer to:
Write a program that takes as input five numbers and outputs the mean (average) and standard...
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
  • 4. Write a C++ program Write a program that takes as input five numbers and outputs...

    4. Write a C++ program Write a program that takes as input five numbers and outputs the mean (average) and standard deviation of the numbers. If the numbers are xi, Xa, x3, Xa, and xs, then the mean is x = (Xi + X2 + X3+ X4 + Xs)/5 and the standard deviation is: Your program must contain at least the following functions: a function that calculates and returns the mean and a function that calculates the standard deviation. 30...

  • Please help! We use Java JGrasp. Write a Java program to take the input of 5...

    Please help! We use Java JGrasp. Write a Java program to take the input of 5 numbers and output the mean (average) and standard deviation of the numbers. If the numbers are x1, x2, x3, x4, and x5, the formula for mean is X = (x1 + x2 + x3 + x4 + x5)/5 And the formula for standard deviation is You can also break standard deviation down like this: 1. Work out the Mean (the simple average of the...

  • Average and Standard Deviation of 4 numbers **c++** Write an input function to input 4 doubles....

    Average and Standard Deviation of 4 numbers **c++** Write an input function to input 4 doubles. then write a function that computes the average of 4 doubles and returns the average and the standard deviation. Write a output routine that shows the 6 numbers. Please feel free to use sub-functions to break up your code.    you can name the four variables a1, a2, a3, a4, or something equally simple as long as you are consistent. Average (or mean) is...

  • Write a program in C++ to calculate the average (mean) and the standard deviation of a...

    Write a program in C++ to calculate the average (mean) and the standard deviation of a list of numbers using vectors. Your program should... Prompt for the number of values the user wishes to enter Prompt the user to enter the values one at a time for the number of requested values into a vector Calculate and display the Mean and Standard Deviation The flow of your code should be similar to: int main() { /** Prompt the user and...

  • In java, write a program that gets 10 integer numbers from the user using user input,...

    In java, write a program that gets 10 integer numbers from the user using user input, and then calculates and display the sum of the numbers that have been read.   Program Requirements: Write the program in three versions with three loops. Put all three loops in the main method of your source code. version1:  use a while loop. version2:  use a do-while loop. version 3:  use a for loop. For each version, use a loop to input 10 int numbers from the user...

  • Write a program that computes the average and standard deviation of four scores. The standard deviation...

    Write a program that computes the average and standard deviation of four scores. The standard deviation is defined to be the square root of the average of the four values. Use two functions. One function to calculate the average, this function should be with Return Type "double". Second Function should be to calculate standard deviation, this function should be with Return Type "void". Allow the program to continue until the user tells the program he/she is finished. This is for...

  • Write a program that takes in a line of text as input, and outputs that line of text in reverse.

    Write a program that takes in a line of text as input, and outputs that line of text in reverse. The program repeats, ending when the user enters "Quit", "quit", or "q" for the line of text.Ex: If the input is:Hello there Hey quitthen the output is:ereht olleH yeHThere is a mistake in my code I can not find. my output is : ereht olleH ereht olleHyeHHow can I fix this?I saw some people use void or the function reverse but we didnt...

  • (1) (50%) Write a C program that takes as input a fully parenthesized, arithmetic expression of...

    (1) (50%) Write a C program that takes as input a fully parenthesized, arithmetic expression of binary operators +, -,*,/, and converts the expression into a binary expression tree. Your program should take input from the command line. The entire expression should be in a character string without any space in it An input string only includes floating numbers in the format of Y.YY, that is, one digit to the left of the decimal point and two digits to the...

  • 4.14 LAB: Convert to binary Write a program that takes in a positive integer as input,...

    4.14 LAB: Convert to binary Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary. For an integer x, the algorithm is: As long as x is greater than 0 Output x % 2 (remainder is either 0 or 1) x = x / 2 Note: The above algorithm outputs the 0's and 1's in reverse order. Ex: If the input is: 6 the output is:...

  • Write a program that calculates the average number of days a company's employees are absent during the year and outputs a report on a file named "employeeAbsences.txt".

    Project DescriptionWrite a program that calculates the average number of days a company's employees are absent during the year and outputs a report on a file named "employeeAbsences.txt".Project SpecificationsInput for this project:the user must enter the number of employees in the company.the user must enter as integers for each employee:the employee number (ID)the number of days that employee missed during the past year.Input Validation:Do not accept a number less than 1 for the number of employees.Do not accept a negative...

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