Program Input Data Mahasiswa Sederhana

virtual
Posts: 4
Joined: Wed Nov 12, 2014 2:46 pm

Program Input Data Mahasiswa Sederhana

Postby virtual » Mon Dec 22, 2014 8:01 am

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

main()
{
awal://menu awal
int pil;
clrscr();
cout<<"------------------------------"<<endl;
cout<<"| PROGRAM DATA MAHASISWA |"<<endl;
cout<<"| PROGRAM STUDI |"<<endl;
cout<<"| S1 TEKHNIK INFORMATIKA |"<<endl;
cout<<"|UNIV.NAHDLATUL ULAMA KALTIM |"<<endl;
cout<<"------------------------------"<<endl;
cout<<"| 1.INPUT DATA |"<<endl;
cout<<"| 2.CARI DATA |"<<endl;
cout<<"| 3.UBAH DATA |"<<endl;
cout<<"| 4.LIHAT DATA |"<<endl;
cout<<"| 5.EXIT PROGRAM |"<<endl;
cout<<"----------------------------"<<endl;
cout<<endl;
cout<<"Masukkan Pilihan (1-4): ";cin>>pil;
if(pil==1)
{
goto input;
}
else if(pil==2)
{
goto cari;
}
else if(pil==3)
{
goto ubah;
}
else if(pil==4)
{
goto print;
}
else if(pil==5)
{
goto end;
}
else
{
cout<<"Pilihan Yang Anda Masukkan Salah\n";
goto awal;
}


input://INPUT
clrscr();
int jml,nim[100],a;
char nama[100][30],semester[100][10],alamat[100][50],prodi[100][20],tgl[100][30];
cout<<"Input Jumlah Mahasiswa : ";cin>>jml;
cout<<"============================\n";
for(a=1;a<=jml;a++)
{
cout<<endl;
cout<<"Input ke-"<<a<<endl;
cout<<"NIM\t\t: 14010-";cin>>nim[a];
cout<<"Nama\t\t: ";gets(nama[a]);
cout<<"Semester\t\t: ";cin>>semester[a];
cout<<"Alamat\t\t: ";gets(alamat[a]);
cout<<"Program Studi\t: ";gets(prodi[a]);
cout<<"Tanggal Lahir\t: ";gets(tgl[a]);
}
getch();
goto awal;

cari://SEARCH
clrscr();
int nimcari;
cout<<"Input NIM Mahasiswa Yang Dicari : ";cin>>nimcari;
for(a=1;a<=jml;a++)
{
if(nimcari==nim[a])
{
cout<<"Data Ditemukan\n";
cout<<"Yaitu :\n";
cout<<"14010"<<nim[a]<<endl;
cout<<"Nama\t\t: "<<nama[a]<<endl;
cout<<"Semester\t\t: "<<semester[a]<<endl;
cout<<"Alamat\t\t: "<<alamat[a]<<endl;
cout<<"Program Studi\t: "<<prodi[a]<<endl;
cout<<"Tanggal Lahir\t: "<<tgl[a]<<endl;
getch();
}
else if(a==jml)
{
cout<<"Maaf Data Tidak Ditemukan"<<endl;
}
else
{
clrscr();
cout<<"Searching....."<<endl;
}
}
goto awal;

ubah://UBAH
clrscr();
int nimubah;
cout<<"Input NIM Mahasiswa Yang Akan Diubah : ";cin>>nimubah;
for(a=1;a<=jml;a++)
{
if(nimubah==nim[a])
{
cout<<"Data Ditemukan\n";
cout<<"Yaitu :\n";
cout<<"14010"<<nim[a]<<endl;
cout<<"Nama\t\t: "<<nama[a]<<"\t(1)"<<endl;
cout<<"Semester\t\t: "<<semester[a]<<"\t(2)"<<endl;
cout<<"Alamat\t\t: "<<alamat[a]<<"\t(3)"<<endl;
cout<<"Program Studi\t: "<<prodi[a]<<"\t(4)"<<endl;
cout<<"Tanggal Lahir\t: "<<tgl[a]<<"\t(5)"<<endl;
cout<<endl;
cout<<endl;

ulang:
char ubahan[100];
int pil2;
cout<<"Pilih Data Yang Ingin Diubah (1-5) : ";cin>>pil2;
if (pil2==1)
{
cout<<"Masukkan Data Baru : ";cin>>ubahan;
strcpy(nama[a],ubahan);
}
else if (pil2==2)
{
cout<<"Masukkan Data Baru : ";cin>>ubahan;
strcpy(semester[a],ubahan);
}
else if (pil2==3)
{
cout<<"Masukkan Data Baru : ";cin>>ubahan;
strcpy(alamat[a],ubahan);
}
else if (pil2==4)
{
cout<<"Masukkan Data Baru : ";cin>>ubahan;
strcpy(prodi[a],ubahan);
}
else if (pil2==5)
{
cout<<"Masukkan Data Baru : ";cin>>ubahan;
strcpy(tgl[a],ubahan);
}
else
{
cout<<"Pilihan Yang Anda Masukkan Salah"<<getch();
goto ulang;
}
}
else if(a==jml)
{
cout<<"Maaf Data Tidak Ditemukan"<<endl;
}
else
{
clrscr();
cout<<"Searching....."<<endl;
cout<<endl;
}

}
goto awal;

print:
clrscr();
cout<<"============================================================================================="<<endl;
cout<<"= No = NIM = NAMA = Alamat = Program Studi = Tanggal Lahir ="<<endl;
cout<<"============================================================================================="<<endl;
for(a=1;a<=jml;a++)
{
cout<<"="<<setiosflags(ios::left)<<setw(4)<<"= ";
cout<<setiosflags(ios::left)<<setw(9)<<"14010"<<nim[a]<<"= ";
cout<<setiosflags(ios::left)<<setw(16)<<nama[a]<<"= ";
cout<<setiosflags(ios::left)<<setw(22)<<alamat[a]<<"= ";
cout<<setiosflags(ios::left)<<setw(16)<<prodi[a]<<"= ";
cout<<setiosflags(ios::left)<<setw(14)<<tgl[a]<<"="<<endl;
}
getch();
goto awal;

end:
clrscr();
cout<<"Program Exiting............"<<endl;
cout<<endl;
cout<<endl;
cout<<endl;
getch();
}

Return to “Share Tugas Informatika”

Who is online

Users browsing this forum: No registered users and 1 guest