Tidak ada niat untuk mengajari hanya ingin berbagi

16 Apr 2016

KASUS 6.2

Assalamualaikum warahmatullahi wabarakatuh...

Kasus 6.2 disuruh untuk Carilah nilai deviasi standar  dari n buah data.
 Kodingan dev C++nya :
#include <iostream>
#include <cmath>
using namespace std;
void calculateMean(double, double);
void calculateStandardDeviation(double, double, double);
void getLetterGrade();
int main()
{
double count;
double score, totalScores = 0.0, mean = 0.0;
cout << "How many scores do you wish to enter? ";
cin >> count;
for (double num = 1.0; num <= count; num++)
{
cout << "Enter score " << num << ": ";
cin >> score;
totalScores = totalScores + score;
}
calculateMean(count, totalScores);
calculateStandardDeviation(count, mean, totalScores);
getLetterGrade();
return 0;
}
void calculateMean(double numberScores, double totalScores)
{
double mean;
mean = (1.0 / numberScores) * totalScores;
cout << "The mean of the scores is " << mean << endl;
}
void calculateStandardDeviation(double mean, double count, double totalScores)
{
double standardDeviation;
standardDeviation = sqrt (((pow(totalScores, 2.0)) - ((1.0/count) * (pow(totalScores,2.0)))) / (count - 1.0));
cout << "The standard deviation of the scores is " << standardDeviation << endl;
}
void getLetterGrade()
{
}

outputnya :

Sekian yang bisa saya bagikan semoga bermanfaat 
wassalamualaikum warahmatullahi wabarakatuh

  

0 komentar:

Posting Komentar

Diberdayakan oleh Blogger.