Selasa, 28 Desember 2010

Program mencari suatu Nilai akhir


#include <iostream.h>
#include <conio.h>
#include <string.h>

struct mahasiswa
{
  long nim;
  char nama[100];
  int uts,uas,tgs;
  float nilai_akhir;
};
void main()
{
 int kode,g,h;

 struct mahasiswa mhs;
 cout<< "\n---------------Program Perhitungan Nilai Akhir---------------\n"<<endl;
 cout<< " MENU perhitungan="<<endl;
 cout<< "1.  Tugas : UTS : UAS = 20% : 30% : 50%"<<endl;
 cout<< "2.  Tugas : UTS : UAS = 30% : 30% : 40%"<<endl;
 cout<< "3.  Tugas : UTS : UAS = 10% : 40% : 50%"<<endl;
 cout <<" Inputkan Nama          : "; cin>>mhs.nama;
 cout <<" Inputkan Nim           : "; cin>>mhs.nim;
 cout <<" Inputkan Nilai Tugas   : "; cin>>mhs.tgs;
 cout <<" Inputkan Nilai UTS     : "; cin>>mhs.uts;
 cout <<" Inputkan Nilai UAS     : "; cin>>mhs.uas;
 cout <<" Inputkan pemilihan Menu Perhitungan     : "; cin>>kode;

 if (kode == 1 )
     {
     mhs.nilai_akhir =(mhs.tgs*0.2)+(mhs.uts*0.3)+(mhs.uas*0.5);
     }
  else if (kode == 2 )
     {
     mhs.nilai_akhir =(mhs.tgs*0.3)+(mhs.uts*0.3)+(mhs.uas*0.4);
     }
  else if (kode == 3 )
     {
     mhs.nilai_akhir=(mhs.tgs*0.1)+(mhs.uts*0.4)+(mhs.uas*0.5);
     }

 cout << " Nilai Akhir ="<<mhs.nilai_akhir<<endl;
 cout<<endl;
 getch();
}

0 komentar: