#include <iostream>
#include <conio.h>
#include <string.h>
struct pgw
{
char nama[20];
int gaji;
int anak;
int anak;
};
pgw pegawai[5];
int klm = 10, klml = klm + 25, brs;
int a = 0;
//kumpulan fungsi..............
void tampilan()
{
clrscr();
klm = 3;
gotoxy(klm, 5);cout << "Isikan data pada index-" << a << endl;
gotoxy(klm, 7);cout << "Nama : ";
gotoxy(klm, 8);cout << "Gaji : ";
gotoxy(klm, 9);cout << "Anak : ";
klm=14;
gotoxy(klm,7);cin >> pegawai[a].nama;
gotoxy(klm,8);cin >> pegawai[a].gaji;
gotoxy(klm,9);cin >> pegawai[a].anak;
klm=3;
}
void nama()
{
gotoxy(klml, 6);cout << "------------";
gotoxy(klml, 6);cin >> pegawai[a].nama;
if (strlen(pegawai[a].nama) < 10) nama();
}
void gaji()
{
gotoxy(klml, 6);cout << "------------";
gotoxy(klml, 6);cin >> pegawai[a].gaji;
}
void tampildata()
{
clrscr();
cout << "==================================" << endl;
cout << "No." << "\t" << "Nama " << "\t" << "Gaji" << "\t" << "Anak\t" << "T Anak" << "\t" <<endl;
cout << "==================================" << endl;
a=0;
do
{
cout << (a+1) << "\t" << pegawai[a].nama << "\t" << pegawai[a].gaji << "\t" << pegawai[a].anak << "\t" << pegawai[a].tanak <<
endl;
a++;
} while (a<5);
cout << "==================================" << endl;
getch();
}
void hittanak()
{
if (pegawai[a].anak > 3)
pegawai[a].tanak = 3 * 50000;
else
pegawai[a].tanak = pegawai[a].anak * 50000;
gotoxy(klm, 10);cout << "T Anak : " << pegawai[a].tanak << "\n\n\n\n";
}
int main()
{
char lagi;
do
{
tampilan();
hittanak();
a++;
gotoxy(klm, 12);cout << "Isi data lagi [Y/T] : "; cin >> lagi;
} while ((a<5) && (lagi=='Y') || (a<5) && (lagi=='y'));
// tampilkan data.........
tampildata();
getch();
}
Program diatas outputnya adalah sebagai berikut :
Silakan di coba ya gan.....:D
Tidak ada komentar:
Posting Komentar