#include <iostream>
#include <conio.h>
#include <string>
#include <fstream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
main(int argc, char *argv[])
{
ofstream file_nilai;
int n,m;
cout<<"\tdata mahasiswa\n";
cout<<"------------------------------------\n";
cout<<"masukkan jumlah mahasiswa : ";
cin>>n;
int o[n];
float p[n],q[n],r[n],s[n];
string a[n];
cout<<endl;
m=0;
while (m<n){
cout<<"nama mahasiswa = ";
cin>>a[m];
cout<<"nim mahasiswa = ";
cin>>o[m];
cout<<"nilai harian = ";
cin>>p[m];
cout<<"nilai uts = ";
cin>>q[m];
cout<<"nilai uas = ";
cin>>r[m];
s[m]=(4*p[m]+4*q[m]+4*r[m])/300;
if(s[m]>=2.00)
{
cout<<"\nnilai akhir = "<<s[m];
cout<<"\nlulus";}
else
{
cout<<"\nnilai akhir = "<<s[m];
cout<<"\nbelum lulus";
}
cout<<endl;
cout<<endl;
m++;
}
file_nilai.open("data.txt");
if (file_nilai == NULL)
{
cout<<"File fail to open";
}
else
{for(m=0;m<n;m++){
file_nilai<<"Tampilkan Data hasilnya\n";
file_nilai<<"NAMA\t\tNIM\t\tHARIAN\tUTS\tUAS\tHASIL\n";
file_nilai<<a[m]<<"\t"<<o[m]<<"\t"<<p[m]<<"\t"<<q[m]<<"\t"<<r[m]<<"\t"<<s[m];
file_nilai.close();
}
getch();
}}
hasil>>>
0 komentar:
Posting Komentar