Contoh Program Switch di C++


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

main ()
{
int pilihan; long saldo, jumlah ;
menu:
gotoxy(30,10);cout<<"------------------------------"<<endl;
gotoxy(30,11);cout<<" PT. BANK SYARIAH BENERAN "<<endl;
gotoxy(30,12);cout<<"------------------------------"<<endl;
gotoxy(30,13);cout<<"Masukkan Saldo:";cin>>saldo;

clrscr();
gotoxy(30,10);cout<<"Menu Transaksi :";
gotoxy(30,12);cout<<"+++++++++++++++++++++++++++++++";
gotoxy(30,13);cout<<"1. Setor Tabungan";
gotoxy(30,14);cout<<"2. Ambil Tabungan";
gotoxy(30,15);cout<<"3. Exit";
gotoxy(30,16);cout<<"+++++++++++++++++++++++++++++++";
gotoxy(30,17);cout<<"Pilihan: ";cin>>pilihan;

clrscr();
switch(pilihan)
{
case 1 :
gotoxy(30,10);cout<<"Jumlah :";cin>>jumlah;
gotoxy(30,10);cout<<"Sisa Saldo: "<<saldo + jumlah;break;
goto menu;

case 2 :
gotoxy(30,10);cout<<"Jumlah :";cin>>jumlah;
gotoxy(30,10);cout<<"Sisa Saldo :"<<saldo - jumlah;break;
goto menu;

case 3 :
goto exit;

default:
gotoxy(30,10);cout<<"Reapet again. Press any key";
}

getch();
goto menu;
exit:
}
◄ Posting Baru Posting Lama ►

------------------------Boost Your Website----------------------

 

Recomended


Free Chat


Copyright © . Art Media Blog - All Rights Reserved TOP