ini adalah Codingan Programnya ....
#include <stdio.h>
#include <conio.h>
void exit();
void menu();
void tunjangan();
void bilangan();
void tanya();
double kalkulator(double a,double b);
double tambah (double a,double b);
double kurang (double a,double b);
double kali (double a,double b);
double bagi (double a,double b);
double a,b,c;
void main()
{
menu();
}
void menu()
{
int
pil;
clrscr();
gotoxy(20,2);
gotoxy(15,2);
printf("=========Menu==========");
gotoxy(15,3);
printf("1.
Kalkulator");
gotoxy(15,4);
printf("2.
Tunjangan");
gotoxy(15,5);
printf("3.
Ganjil Genap");
gotoxy(15,6);
printf("4.
Keluar");
gotoxy(15,8);
printf("=======================");
gotoxy(15,9);
printf("Masukkan
Pilihan : ");
scanf("%i",&pil);
switch(pil)
{
case
1 : clrscr();
kalkulator(a,b);
break;
case
2 : clrscr();
tunjangan();
break;
case
3 : clrscr();
bilangan();
break;
case
4 : clrscr();
exit();
default:
gotoxy(15,10);
printf("Maaf Input Yang Anda Masukkan
Salah");
}
getch();
}
double kalkulator(double a,double b)
{
printf("1.
Kalkulator\n");
printf("=======================");
printf("\nAngka
Pertama : ");
scanf("%lg",&a);
printf("\nAngka
Kedua : ");
scanf("%lg",&b);
tambah(a,b);
kurang(a,b);
bagi(a,b);
kali(a,b);
tanya();
getch();
return
0;
}
double tambah(double a,double b)
{
c=a+b;
printf("\n%lg
+ %lg = %lg\n",a,b,c);
return
c;
}
double kurang(double a,double b)
{
c=a-b;
printf("\n%lg
- %lg = %lg\n",a,b,c);
return
c;
}
double bagi(double a,double b)
{
c=a/b;
printf("\n%lg
/ %lg = %lg\n",a,b,c);
return
c;
}
double kali(double a,double b)
{
c=a*b;
printf("\n%lg
* %lg = %lg\n",a,b,c);
return
c;
}
void tunjangan()
{
int
gk, ja;
float
pt, tun;
printf("\n2.
Hitung Tunjangan");
printf("\n=====================");
printf("\nGaji
Kotor? ");
scanf("%d",
& gk);
printf("\nJumlah
Anak? ");
scanf("%d",
& ja);
pt=0.2;
if(ja>2)
pt=0.3;
tun=pt*gk;
printf("\nBesar
Tunjangan = Rp %.2f", tun);
tanya();
getch();
}
void bilangan()
{
int bil;
printf("\n3. Ganjil Genap");
printf("\n=====================");
printf("\nMasukkan Angka = ");
scanf("%d", & bil);
if(bil==0)
printf("\nAngka %d bukan ganjil bukan
genap", bil);
else if(bil %2==0)
{
printf("\nAngka %d adalah bilangan
genap", bil);
}
else
{
printf("\nAngka %d adalah bilangan
ganjil", bil);
}
tanya();
getch();
}
void tanya()
{
char
jwb;
printf("\nKembali
Ke Menu (Y/T)? ");
jwb=getche();
if
(jwb=='Y'||jwb=='y')
menu();
else
exit();
}
void exit()
{
gotoxy(1,1);
printf("Terima
Kasih");
getch();
}
Belum ada tanggapan untuk "Program Menu pada C++"
Posting Komentar