// nilaimahasiswa.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
using namespace std;
void garis()
{
cout<<"=================================="<<endl;
}
int _tmain(int argc, _TCHAR* argv[])
{
//definidikan variabel
char npm[10];
char nama[20];
int nh,uts,tm,uas;
double rata2;
char grade;
char* keterangan;
//input
cout<<"masukan npm anda : "; cin.getline(npm, sizeof(npm)+1);
cout<<"masukan nama anda : "; cin.getline(nama, sizeof(nama)+1);
cout<<"masukan nilai kehadiran : "; cin>>nh;
cout<<"masukan nilai uts : "; cin>>uts;
cout<<"masukan nilai tugas : "; cin>>tm;
cout<<"masukan nilai uas : "; cin>>uas;
cout<<endl<<endl;
//proses
rata2=(0.1*nh)+(0.25*uts)+(0.15*tm)+(0.5*uas);
//output
garis();
cout<<"BIODATA MAHASISWA: "<<npm<<endl;
garis();
cout<<" npm mahasiswa : "<<npm<<endl;
cout<<" nama mahasiswa : "<<nama<<endl;
cout<<" nilai kehadiran : "<<nh<<endl;
cout<<" nilai uts : "<<uts<<endl;
cout<<" nilai tugas : "<<tm<<endl;
cout<<" nilai uas : "<<uas<<endl;
garis();
cout<<"nilai rata-rata : "<<rata2<<endl;
garis();
//proses mencari nilai grade
if (rata2>=80) {
grade='A';
} else if (rata2>70 && rata2>80) {
grade='B';
} else if (rata2>60 && rata2>70) {
grade='C';
} else if (rata2>40 && rata2>50) {
grade='D';
} else {
grade='e';
}
switch(grade) {
case 'A' :
keterangan="sangat memuaskan";
break;
case 'B' :
keterangan="memuaskan";
break;
case 'C' :
keterangan="cukup";
break;
case 'D' :
keterangan="kurang dari cukup";
break;
default :
keterangan="GAGAL";
break;
}
cout<<"nilai grade : "<<grade<<endl;
cout<<"predikat nilai : "<<keterangan<<endl;
garis();
cout<<endl<<endl;
system("pause");
return 0;
}
//
#include "stdafx.h"
#include <iostream>
using namespace std;
void garis()
{
cout<<"=================================="<<endl;
}
int _tmain(int argc, _TCHAR* argv[])
{
//definidikan variabel
char npm[10];
char nama[20];
int nh,uts,tm,uas;
double rata2;
char grade;
char* keterangan;
//input
cout<<"masukan npm anda : "; cin.getline(npm, sizeof(npm)+1);
cout<<"masukan nama anda : "; cin.getline(nama, sizeof(nama)+1);
cout<<"masukan nilai kehadiran : "; cin>>nh;
cout<<"masukan nilai uts : "; cin>>uts;
cout<<"masukan nilai tugas : "; cin>>tm;
cout<<"masukan nilai uas : "; cin>>uas;
cout<<endl<<endl;
//proses
rata2=(0.1*nh)+(0.25*uts)+(0.15*tm)+(0.5*uas);
//output
garis();
cout<<"BIODATA MAHASISWA: "<<npm<<endl;
garis();
cout<<" npm mahasiswa : "<<npm<<endl;
cout<<" nama mahasiswa : "<<nama<<endl;
cout<<" nilai kehadiran : "<<nh<<endl;
cout<<" nilai uts : "<<uts<<endl;
cout<<" nilai tugas : "<<tm<<endl;
cout<<" nilai uas : "<<uas<<endl;
garis();
cout<<"nilai rata-rata : "<<rata2<<endl;
garis();
//proses mencari nilai grade
if (rata2>=80) {
grade='A';
} else if (rata2>70 && rata2>80) {
grade='B';
} else if (rata2>60 && rata2>70) {
grade='C';
} else if (rata2>40 && rata2>50) {
grade='D';
} else {
grade='e';
}
switch(grade) {
case 'A' :
keterangan="sangat memuaskan";
break;
case 'B' :
keterangan="memuaskan";
break;
case 'C' :
keterangan="cukup";
break;
case 'D' :
keterangan="kurang dari cukup";
break;
default :
keterangan="GAGAL";
break;
}
cout<<"nilai grade : "<<grade<<endl;
cout<<"predikat nilai : "<<keterangan<<endl;
garis();
cout<<endl<<endl;
system("pause");
return 0;
}
Tidak ada komentar:
Posting Komentar