Main.cpp
#include <iostream>
#include "ADTNasabah.h"
#include <cstdlib>
using namespace std;
int main()
{
nasabah n;
listnasabah l;
l.jumnasbah=0;
int pil;
do{
system("cls");
cout << "Menu Utama Teller Bank IF" <<endl
<< "=========================" <<endl
<< "1. Pendaftaran Nasabah Baru" <<endl
<< "2. Setoran"<<endl
<< "3. Penarikan"<<endl
<< "4. Transfer Antar Rekening"<<endl
<< "5. Lihat Semua Nasabah"<<endl
<< "6. Keluar"<<endl
<< "Pilihan Menu : ";cin >> pil;
if (pil==1)
{inputnasabahbaru(n,&l);};
if (pil==2)
{
setoran(&l);
};
if (pil==3)
{
penarikan(&l);
};
if (pil==4)
{
};
if (pil==5)
{
viewnasabah(l);
};
}while(pil!=6);
}
ADTNasabah.cpp
#include <iostream>
#include "ADTNasabah.h"
#include <conio.h>
#include <string.h>
using namespace std;
void inputnasabahbaru(nasabah n, listnasabah *l)
{
cout << endl;
cout << "No.Rekening : "; cin >>n.norek;
cout << "Nama : "; cin >>n.nama;
cout << "Saldo Awal : "; cin >>n.saldo;
if (n.saldo<100000)
cout <<endl<< "Pendaftaran nasabah baru gagal." <<endl
<< "Minimum setoran awal = 100.000";
else
{
if(l->jumnasbah<20){
l->nasbah[l->jumnasbah]=n;
l->jumnasbah++;
cout <<endl<< "Pendaftaran nasabah baru berhasil.";
}
else
cout<<"list sudah penuh.";
}
cout << endl<<endl<<"Press any key to continue . . . ";
getch();
}
void viewnasabah (listnasabah l)
{
for (int i=0 ; i<l.jumnasbah ; i++){
cout << endl
<< "Daftar Nasabah"<<endl
<< "=============="<<endl
<< "Nasabah "<<i<<endl
<< "No. Rek : "<<l.nasbah[i].norek<<endl
<< "Nama : "<<l.nasbah[i].nama<<endl
<< "Saldo : "<<l.nasbah[i].saldo<<endl<<endl;
}
cout<< "Press any key to continue . . . ";
getch();
}
void setoran (listnasabah *l)
{
int carirek,ut,x;
cout << "Masukkan nomor rekening : "; cin >>carirek;
for (int i=0 ; i<l->jumnasbah ; i++){
if (carirek==l->nasbah[i].norek)
cout << "Nama : "<<l->nasbah[i].nama<<endl;
x=i;}
cout <<endl<< "Masukkan jumlah setoran : ";cin>>ut;
l->nasbah[x].saldo=l->nasbah[x].saldo+ut;
cout << endl<<"Transaksi setoran berhasil."
<< endl<<"press any key to continue . . .";
getch();
}
void penarikan (listnasabah *l)
{
int carirek,ut,x;
cout << "Masukkan nomor rekening : "; cin >>carirek;
for (int i=0 ; i<l->jumnasbah ; i++){
if (carirek==l->nasbah[i].norek)
cout << "Nama : "<<l->nasbah[i].nama<<endl;
x=i;}
cout <<endl<< "Masukkan jumlah penarikan : ";cin>>ut;
l->nasbah[x].saldo=l->nasbah[x].saldo-ut;
cout << endl<<"Transaksi penarikan berhasil."
<< endl<<"press any key to continue . . .";
getch();
}
void transfer (listnasabah *l)
{
int carirek,carirek2,ut,x,y;
cout << "Masukkan nomor rekening asal: "; cin >>carirek;
cout << "Masukkan nomor rekening tujuan: "; cin >>carirek2;
cout <<endl;
for (int i=0 ; i<l->jumnasbah ; i++){
if (carirek==l->nasbah[i].norek)
cout << "Nama Pengirim: "<<l->nasbah[i].nama;
x=i;}
for (int i=0 ; i<l->jumnasbah ; i++){
if (carirek2==l->nasbah[i].norek)
cout << "Nama Penerima: "<<l->nasbah[i].nama<<endl;
y=i;}
cout <<endl<< "Masukkan jumlah transfer : ";cin>>ut;
l->nasbah[x].saldo=l->nasbah[x].saldo-ut;
l->nasbah[y].saldo=l->nasbah[y].saldo+ut;
cout << endl<<"Transaksi transfer berhasil."
<< endl<<"press any key to continue . . .";
getch();
}
ADTNasabah.h
#ifndef ADTNASABAH_H_INCLUDED
#define ADTNASABAH_H_INCLUDED
typedef struct{
int norek;
char nama[50];
long saldo;
}nasabah;
typedef struct{
nasabah nasbah[20];
int jumnasbah;
}listnasabah;
void inputnasabahbaru(nasabah n, listnasabah *l);
void viewnasabah (listnasabah l);
void setoran (listnasabah *l);
void penarikan (listnasabah *l);
#endif // ADTNASABAH_H_INCLUDED
0 komentar:
Post a Comment