Question

Write a program, using C#, that will find the mean and standard deviation of a number...

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.

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

using System;

namespace Mean_Standard_Deviation
{
   class MainClass
   {
       public static void Main (string[] args)
       {
           //declare number of data points
           int n;
           //declare sum, mean,standard deviation
           double sum=0.0,mean,standardDeviation,total=0.0;
           //Input data points
           Console.WriteLine("Enter number of data points");
           n=Convert.ToInt32(Console.ReadLine());
           //declare array of data points
           double[] points=new double[n];
           //Input the data points
           Console.WriteLine("Enter points");
           for(int i=0;i<n;++i)
           points[i]=Convert.ToDouble(Console.ReadLine());
           //calulate sum
           for(int i=0;i<n;++i)
           sum+=points[i];
           //calculate mean
           mean=sum/n;
           //calculate standard deviation
           for(int i=0;i<n;++i)
           total+=(points[i]-mean)*(points[i]-mean);
           standardDeviation=Math.Sqrt((total/n));
           Console.WriteLine ("Mean = {0}",mean);
           Console.WriteLine ("Standard Deviation = {0}",standardDeviation);
       }
   }
}

Output

Add a comment
Know the answer?
Add Answer to:
Write a program, using C#, that will find the mean and standard deviation of a number...
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 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 C++, Write a program that retrieves a phone number from a txt files of names...

    In C++, Write a program that retrieves a phone number from a txt files of names and phone numbers. The program should ask the user to enter a name and then print the phone number of that person (or vice versa, number into name) The program should allow the user to repeat the operation as often as they would like to. The data is contained in two text files named "phoneNames.txt" and "phoneNums.txt". The files have one name or one...

  • 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...

  • Must be done in python and using linux mint Write a program to create a text...

    Must be done in python and using linux mint Write a program to create a text file which contains a sequence of test scores. Each score will be between 0 and 100 inclusive. There will be one value per line, with no additional text in the file. Stop adding information to the file when the user enters -1 The program will first ask for a file name and then the scores. Use a sentinel of -1 to indicate the user...

  • C++ (1) Write a program to prompt the user for an input and output file name....

    C++ (1) Write a program to prompt the user for an input and output file name. The program should check for errors in opening the files, and print the name of any file which has an error, and exit if an error occurs. For example, (user input shown in caps in first line, and in second case, trying to write to a folder which you may not have write authority in) Enter input filename: DOESNOTEXIST.T Error opening input file: DOESNOTEXIST.T...

  • **** Using java write a program that finds the standard deviation of a set of numbers....

    **** Using java write a program that finds the standard deviation of a set of numbers. it also has to prompt the user to enter a set of numbers.

  • Write a C++ program using "for" loop to allow user to guess a certain number say...

    Write a C++ program using "for" loop to allow user to guess a certain number say 55. The loop will end after 5 guesses or if he guesses the right number, which ever comes first. If user enters a number greater than 55, your program should print "You entered a bigger number". If user enters a number smaller than 55, your program should print "You entered a smaller number". If user enters 55 in less than 5 attempt, your program...

  • Please write this in C. Write this code in Visual Studio and upload your Source.cpp file for checking (1) Write a program to prompt the user for an output file name and 2 input file names. The progra...

    Please write this in C. Write this code in Visual Studio and upload your Source.cpp file for checking (1) Write a program to prompt the user for an output file name and 2 input file names. The program should check for errors in opening the files, and print the name of any file which has an error, and exit if an error occurs opening any of the 3 For example, (user input shown in caps in first line) Enter first...

  • Program in C++! Thank you in advance! Write a menu based program implementing the following functions: (1) Write a funct...

    Program in C++! Thank you in advance! Write a menu based program implementing the following functions: (1) Write a function that prompts the user for the name of a file to output as a text file that will hold a two dimensional array of the long double data type. Have the user specify the number of rows and the number of columns for the two dimensional array. Have the user enter the values for each row and column element in...

  • Please do it in C language. MAE 2360 S20 Lab 4 1. Write a program to...

    Please do it in C language. MAE 2360 S20 Lab 4 1. Write a program to simulate the rolling of one six sided die 20 times and print the results a. to the screen first. b. to a file using" > ". Use cat to view the file. C. Modify the program to save the results in an array. d. Repeat for 2 dice, saving to a different file name. 2. Write a program to calculate and print mean and...

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