#include <cstdlib>
#include <iostream>
using namespace std;
class data{
private : float i;
float n;
float jumlah;
float x;
float rata;
public :
data();
void nilai();
};
data::data(){
cout<<"Menghitung Rata-Rata "<<endl;
}
void data::nilai(){
cout<<"Masukkan Jumlah Data=";
cin>>n;
jumlah=0;
for (i=1; i<=n;i++) {
cout<<"Data ke-"<<i<<"=";
cin>>x;
jumlah +=x;
}
rata=jumlah/n;
cout<<endl;
cout<<"Rata-rata="<<rata<<endl;
cout<<endl;
}
int main(int argc, char *argv[])
{
data a;
a.nilai();
system("PAUSE");
return EXIT_SUCCESS;
}
0 komentar:
Posting Komentar