1. Buatlah program input pemasukan data nilai mahasiswa, yang memuat :
NIM, nama, nilai tugas, nilai UAS, nilai UTS.
2. Jawaban :
#include <conio.h>
#include <iostream.h>
#include <iomanip.h>
#include <stdio.h>
void main()
{
int i, data;
char nama[10][20],nim[10][5];
float nilaitgs[10];
float nilaiuts[10];
float nilaiuas[10];
float hasil[10];
cout<<"Data Yang Akan Diinputkan : ";cin>>data;
for(i=0;i<data;i++)
{
cout<<" Data Ke - "<<i+1<<endl;
cout<<" NIM Siswa : "; gets(nim[i]);
cout<<" Nama Siswa : "; gets(nama[i]);
cout<<" Nilai Tugas : "; cin>>nilaitgs[i];
cout<<" Nilai UTS : "; cin>>nilaiuts[i];
cout<<" Nilai UAS : "; cin>>nilaiuas[i];
hasil[i] = (nilaitgs[i] * 0.2) + (nilaiuts[i] * 0.3) + (nilaiuas[i] * 0.5);
cout<<" Nilai Akhir : "<<hasil[i]<<endl;
}
cout<<"-----------------------------------------------------------------------------"<<endl;
cout<<"No NIM Nama Siswa Nilai Nilai Nilai Hasil Nilai"<<endl;
cout<<" Tugas UTS UAS Ujian Huruf"<<endl;
cout<<"-----------------------------------------------------------------------------"<<endl;
for(i=0;i<data;i++)
{
cout<<setiosflags(ios::left)<<setw(4)<<i+1;
cout<<setiosflags(ios::left)<<setw(10)<<nim[i];
cout<<setiosflags(ios::left)<<setw(15)<<nama[i];
cout<<setprecision(2)<<" "<<nilaitgs[i];
cout<<setprecision(2)<<" "<<nilaiuts[i];
cout<<setprecision(2)<<" "<<nilaiuas[i];
cout<<setprecision(2)<<" "<<hasil[i];
if (hasil[i]>=90)
cout<<" A"<<endl;
else if(hasil[i]>=80)
cout<<" B"<<endl;
else if(hasil[i]>=70)
cout<<" C"<<endl;
else if (hasil[i]>=60)
cout<<" D"<<endl;
else
cout<<" E"<<endl;
}
cout<<"----------------------------------------------------------------------------"<<endl;
getch();
}
0 komentar:
Posting Komentar