Hi,
You would need to put it in a while loop
Code:
# include <iostream>
# include <cmath>
#include <conio.h> //for use of getch()
using namespace std;
double average, sd, s1, s2, s3, s4, deviation;
char yesno = 'y'; //while loop control variable
int main()
{
while (yesno!='n'&&yesno!='N') //will execute as long as yesno is not equal to 'n' or 'N'
{
cout << "Press enter after entering a value.\n";
cout << endl;
cout << "Enter score one: ";
cin >> s1;
cout << "\nEnter score two: ";
cin >> s2;
cout << "\nEnter score three: ";
cin >> s3;
cout << "\nEnter score four: ";
cin >> s4;
average =(s1+s2+s3+s4)/4;
deviation =(((s1-average)*(s1-average))+((s2-average)*(s2- average))+((s3-average)*(s3-average))+((s4-average)*(s4- average)))/3;
sd = sqrt(deviation);
cout << "\nThe average of your four scores is "<<average<<".\n";
cout << "The standard deviation of your scores is "<<sd<<".\n";
cout<<"Would you like to run the program again?";
cin>>yesno;
}
cout<<"Thankyou bye";
getch();
return 0;
}
I hope this isn't too confusing, you seem to know what you are on about.