Sunday, January 10, 2016

Final Project DDP "Rekap Nilai"

link youtube : https://www.youtube.com/watch?v=e-FvMB9PEi0

#include <iostream>
#include <stdio.h>
#include <iomanip>

using namespace std;
typedef struct
{
char kodeMKA[50];
char kelas[5];
int UTS;
} A[50];

typedef struct
{
int nim;
char nama[100];
int MKA;
A kuliah;
} B[100];

int values[100];
bool found;


int main(){
cout<<" \t \t \t  Program Rekap Nilai UTS \n ";
cout<<" \t \t \t ____________________________ \n \n";

FILE *ArsipMhs;
FILE *banyakMhs;
int Mhs = 0;
int pilihan;
int i,j,a;
B mhs;
do
{
cout << " 1. Input Data \t \t ";
cout << " 2. Output Data \t \t ";
cout << " 3. Keluar \n \n";
cout << "Pilihan : ";
cin >> pilihan;
switch (pilihan)
{
case 1 :
{
cout << "\n" ;
cout << "input data mahasiswa\n";
cout << "=============================\n";
banyakMhs = fopen("banyakMhs.txt","wb");
cout << "   Banyaknya Mahasiswa \t: ";
cin >> Mhs;
fwrite(&Mhs,sizeof(Mhs),1,banyakMhs);
cout << "\n";
if((ArsipMhs = fopen("Arsip.txt","wb"))==NULL)
{
cout << "File tak dapat diciptakan !! \r\n";
}
else{

for (i=0; i<Mhs; i++)
{
cout << i+1 << ". No Mahasiswa \t: "; cin >> mhs[i].nim;
cout << "   Nama Mahasiswa \t: "; cin>>mhs[i].nama;
cout << "   Banyak Mata Kuliah \t: "; cin >> mhs[i].MKA;
cout << "\n";
cout << "==============================================\n";
for (j=0; j<mhs[i].MKA; j++ )
{
cout<<"Kode Mata Kuliah "<<j+1<<" : ";
cin >> mhs[i].kuliah[j].kodeMKA;
cout<<"Kelas \t \t : ";
cin >> mhs[i].kuliah[j].kelas;
cout<<"Nilai UTS \t : ";
cin >> mhs[i].kuliah[j].UTS;
fwrite(&mhs,sizeof(mhs),1,ArsipMhs);
}
fwrite(&mhs,sizeof(mhs),1,ArsipMhs);
cout << "\n";
}}
fclose(banyakMhs);
fclose(ArsipMhs);
break;
}
case 2 :
{
banyakMhs = fopen("banyakMhs.txt","rb");
fread(&Mhs,sizeof(Mhs),1,banyakMhs);
if((ArsipMhs = fopen("Arsip.txt","rb"))==NULL)
{
cout << "File tak dapat dibuka\n";
exit(1);
}
cout << "\n=========================\n" ;
cout << "output data mahasiswa\n";
cout << "=========================\n";
fread(&mhs,sizeof(mhs),1,ArsipMhs);
for (i=0; i<Mhs; i++)
{

cout << "\n";
cout << i+1 << ". No Mahasiswa \t: " << mhs[i].nim << "\n";
cout << "   Nama Mahasiswa \t: " << mhs[i].nama << "\n";
cout << "   Banyak MKA \t\t: " <<  mhs[i].MKA << "\n";

cout << "\n";
cout << "-------------------------------------------------------------------\n";
cout << "  |\tKode MKA\t|\tKelas\t|\tNilai UTS\t|\n";
cout << "-------------------------------------------------------------------\n";

for (j=0; j<mhs[i].MKA; j++)
{
cout << "  |\t" <<  mhs[i].kuliah[j].kodeMKA ;
cout << "\t\t|\t " << mhs[i].kuliah[j].kelas ;
cout << "\t|\t " << mhs[i].kuliah[j].UTS << "  \t\t|\n"<<endl;
fread(&mhs,sizeof(mhs),1,ArsipMhs);
}

fread(&mhs,sizeof(mhs),1,ArsipMhs);
}
fclose(ArsipMhs);
fclose(banyakMhs);
break;
}
case 3 :
{
exit(1);
break;
}
}
}while (pilihan != 3);
}






EmoticonEmoticon