Write a program in C++ to calculate the average (mean) and the standard deviation of a list of numbers using vectors.
Your program should...
The flow of your code should be similar to:
int main() { /** Prompt the user and get the number of values to enter **/ /** Get the values from the user and store in a vector **/ /** Calculate and display the mean and standard deviation **/ return 0; }
#include <iostream> #include <vector> #include <cmath> using namespace std; int main() { int n; /** Prompt the user and get the number of values to enter **/ cout<<"Number of values you wishes to enter: "; cin>>n; /** Get the values from the user and store in a vector **/ vector<double> v; double val; for(int i = 0;i<n;i++){ cin>>val; v.push_back(val); } /** Calculate and display the mean and standard deviation **/ double sum = 0; for(int i = 0; i<n; i++) { sum += v[i]; } double mean = sum/n; cout<<"Mean = "<<mean<<endl; double sd = 0; for (int i = 0; i<n; i++) { sd += pow(v[i] - mean, 2); } sd = sqrt(sd / (n - 1)); cout<<"Standard deviation = "<<sd<<endl; return 0; }
Write a program in C++ to calculate the average (mean) and the standard deviation of a...
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...
Fix the following program (C++). #include <iostream> #include <cmath> #include <vector> #include <limits> using namespace std; /* * Calculate the square of a number */ float square (float x) { return x*x; } /* * Calculate the average from a list of floating point numbers */ float average(vector<float>& values) { float sum = 0.0f; float average; for (float x : values) sum += x; average = sum / values.size(); return average; } /** Calculate the standard deviation from a vector...
need help!! c++ HW_6b - Calculate the average Use a do-while loop Write a program that first prompts the user for an upper limit: Enter the number of entries: 5 € (user enters 5) After the user enters a number, the program should prompt the user to enter that many numbers. For example, if the user enters 5, then the program will ask the user to enter 5 values. Use a do-while loop to add the numbers. o With each...
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...
C++ programming For this assignment, write a program that will act as a geometry calculator. The program will be menu-driven and should continue to execute as long as the user wants to continue. Basic Program Logic The program should start by displaying a menu similar to the following: Geometry Calculator 1. Calculate the area of a circle 2. Calculate the area of a triangle 3. Quit Enter your choice(1-3): and get the user's choice as an integer. After the choice...
Write a program, using C#, that will find the mean and standard deviation of a number of data points. The ONE PROGRAM should allow the user to enter data manually OR via a text file.
C Programming For this task, you will have to write a program that will prompt the user for a number N. Then, you will have to prompt the user for N numbers, and print then print the sum of the numbers. For this task, you have to create and use a function with the following signature: int sum(int* arr, int n); Your code should look something like this (you can start with this as a template: int sum(int* arr, int...
5.19 Ch 5 Program: Soccer team roster (Vectors) (C++) This program will store roster and rating information for a soccer team. Coaches rate players during tryouts to ensure a balanced team. (1) Prompt the user to input five pairs of numbers: A player's jersey number (0 - 99) and the player's rating (1 - 9). Store the jersey numbers in one int vector and the ratings in another int vector. Output these vectors (i.e., output the roster). (3 pts) Ex:...
C program help: Write a C program that uses three functions to perform the following tasks: – The first function should read the price of an item sold at a grocery store together with the quantity from the user and return all the values to main(). example: #include void getInput(int *pNum1, int *pNum2); // note: *pNum1 & *pNum2 are pointers to ints int main () { int numDucks,numCats; getInput(&numDucks, &numCats); // passing addresses of num1 & num2 to...
I need to Write a test program that prompts the user to enter 10 double values into an array, calls a method to calculate the average of the numbers, and displays the average. Next, write a method that returns the lowest value in the array and display the lowest number. The program should then prompt the user to enter 10 integer values into an array, calculates the average, and displays the average. The program should have two overloaded methods to...