Contoh UAS Soal Praktek C++

#include <stdio>
#include <iostream>
#include <conio>
#include <iomanip>
garis(){
puts(“‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐\n”);
}
header(){
puts(“Program input NilaiMahasiswa \n”
“UjianAkhir Semester \n”
“2012‐2013 \n”);
}
intn_akhir(intabsen, inttugas, intuts, intuas){
intna=(0.1*absen)+(0.2*tugas)+(0.3*uts)+(0.4*uas);
returnna;
}
char grade(intna){
if(na>85 &&na<=100)
return ‘A’;
if(na>70 &&na<=85)
return ‘B’;
if(na>=60 &&na<=70)
return ‘C’;
if(na>30 &&na<=59)
return ‘D’;
if(na>0 &&na<=30)
return ‘E’;
}
main(){
struct{
intnim;
charnama[20];
intnabsen, ntugas, nuts, nuas;
}datamhs[100];
charmatkul[20];
intjmhs; float nrata2=0;
header();
garis();
cout<<“input Mata Kuliah : “; gets(matkul);
cout<<“input JumlahMhs : “; cin>>jmhs;
garis();
for(inti=1;i<=jmhs;i++){
cout<<“Data ke‐”<<i<<endl;
cout<<“Input Nim :”; cin>>datamhs[i].nim;
cout<<“Input Nama :”; gets(datamhs[i].nama);
cout<<“NilaiAbsen :”; cin>>datamhs[i].nabsen;
cout<<“NilaiTugas :”; cin>>datamhs[i].ntugas;
cout<<“NilaiUts :”; cin>>datamhs[i].nuts;
cout<<“NilaiUas :”; cin>>datamhs[i].nuas;
int nilai_akhir=n_akhir(datamhs[i].nabsen,datamhs[i].ntugas,datamhs[i].nuts,datamhs[i].nuas);
cout<<“NilaiAkhir :”<<nilai_akhir<<endl<<endl;
}
clrscr();
header();
garis();
cout<<“Mata kuliah :”<<matkul<<endl;
garis();
cout<<“No. NIM NamaMhsNilaiAkhr Grade \n”;
garis();
for(inti=1;i<=jmhs;i++){
cout<<setiosflags(ios::left)<<setw(4)<<i;
cout<<setiosflags(ios::left)<<setw(10)<<datamhs[i].nim;
cout<<setiosflags(ios::left)<<setw(15)<<datamhs[i].nama;
int nilai_akhir=n_akhir(datamhs[i].nabsen,datamhs[i].ntugas,datamhs[i].nuts,datamhs[i].nuas);
cout<<setiosflags(ios::right)<<setw(10)<<nilai_akhir;
cout<<setiosflags(ios::right)<<setw(4)<<grade(nilai_akhir)<<endl;
nrata2+=nilai_akhir;
}
garis();
cout<<“Nilai rata‐rata mahasiswaadalah “<<(nrata2/jmhs)<<endl;
getch();
}

Komentar Disini

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s