14.10.15
11.10.15
Program C++ Latihan Mini Market dengan Diskon
#include <conio.h>
#include <iostream.h>
#include <stdio.h>
void main()
{
int a,b,c,d,e,f,g,h;
cout << " PROGRAM BY TRY PW "<<endl;
cout <<endl;
cout << "============================" <<endl;
cout << " GESREK MINI MARKET" <<endl;
cout << "============================" <<endl;
cout << "1. Beras : Rp. ";cin>>a;
cout << "2. Terigu : Rp. ";cin>>b;
cout << "3. Minyak Goreng : Rp. ";cin>>c;
cout << "4. Telur : Rp. ";cin>>d;
cout << "5. Mentega : Rp. ";cin>>e;
cout << "============================" <<endl;
f=a+b+c+d+e;
cout << "Total Belanja : Rp. " << f << endl;
if (f >= 100000 && f)
{
g=(f*10)/100;
cout<<endl;
cout << "Selamat Anda mendapat Diskon 10% "<<endl;
cout<<endl;
cout << "Diskon 10% : Rp. " << g <<endl;
}
else if (f >= 0 && f < 100000)
{
g=(f*5)/100;
cout<<endl;
cout << "Selamat Anda mendapat Diskon 5% "<<endl;
cout<<endl;
cout << "Diskon 5% : Rp. " << g <<endl;
}
h=f-g;
cout << "Total Pembayaran : Rp. "<<h<<endl;
getch();
}
#include <iostream.h>
#include <stdio.h>
void main()
{
int a,b,c,d,e,f,g,h;
cout << " PROGRAM BY TRY PW "<<endl;
cout <<endl;
cout << "============================" <<endl;
cout << " GESREK MINI MARKET" <<endl;
cout << "============================" <<endl;
cout << "1. Beras : Rp. ";cin>>a;
cout << "2. Terigu : Rp. ";cin>>b;
cout << "3. Minyak Goreng : Rp. ";cin>>c;
cout << "4. Telur : Rp. ";cin>>d;
cout << "5. Mentega : Rp. ";cin>>e;
cout << "============================" <<endl;
f=a+b+c+d+e;
cout << "Total Belanja : Rp. " << f << endl;
if (f >= 100000 && f)
{
g=(f*10)/100;
cout<<endl;
cout << "Selamat Anda mendapat Diskon 10% "<<endl;
cout<<endl;
cout << "Diskon 10% : Rp. " << g <<endl;
}
else if (f >= 0 && f < 100000)
{
g=(f*5)/100;
cout<<endl;
cout << "Selamat Anda mendapat Diskon 5% "<<endl;
cout<<endl;
cout << "Diskon 5% : Rp. " << g <<endl;
}
h=f-g;
cout << "Total Pembayaran : Rp. "<<h<<endl;
getch();
}
Program C++ Tiket Pesawat
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
#include<iomanip.h>
#include<string.h>
main()
{
char nm_pesawat[20],kd_pesawat[20],lagi;
int kls_pesawat,hrg_tiket,jml_tiket,total_bayar;
awal:
clrscr();
cout<<"\t\t\t\t PROGRAM BY TRY PW "<<endl;
cout<<endl<<endl;
cout<<"\t\t\t\tPROGRAM TIKET PESAWAT"<<endl;
cout<<"\t\t\t\tJAKARTA - MALAYSIA"<<endl;
cout<<"--------------------------------------------------------------------------------"<<endl;
cout<<"Masukan Kode Pesawat [MPT/GRD/BTV] :";gets(kd_pesawat);
cout<<"\nKelas Pesawat:"<<endl;
cout<<"\t 1. Executive"<<endl;
cout<<"\t 2. Bisnis"<<endl;
cout<<"\t 3. Ekonomis"<<endl;
cout<<"Pilih Kelas [1/2/3]:";cin>>kls_pesawat;
if(strcmp(kd_pesawat,"MPT")==0)
{
strcpy(nm_pesawat,"MERPATI");
if(kls_pesawat==1)
(hrg_tiket=1500000);
else if(kls_pesawat==2)
(hrg_tiket=900000);
else if(kls_pesawat==3)
(hrg_tiket=500000);
else(hrg_tiket=0);
}
else if(strcmp(kd_pesawat,"GRD")==0)
{
strcpy(nm_pesawat,"GARUDA");
if(kls_pesawat==1)
(hrg_tiket=1200000);
else if(kls_pesawat==2)
(hrg_tiket=800000);
else if(kls_pesawat==3)
(hrg_tiket=400000);
else(hrg_tiket=0);
}
else if(strcmp(kd_pesawat,"BTV")==0)
{
strcpy(nm_pesawat,"BATAVIA");
if(kls_pesawat==1)
(hrg_tiket=1000000);
else if(kls_pesawat==2)
(hrg_tiket=700000);
else if(kls_pesawat==3)
(hrg_tiket=300000);
else(hrg_tiket=0);
}
printf("\n");
printf("\NAMA PESAWAT :%s",nm_pesawat);
printf("\nHARGA TIKET :%d",hrg_tiket);
printf("\n");
cout<<"JUMLAH TIKET :",cin>>jml_tiket;
total_bayar=hrg_tiket*jml_tiket;
printf("TOTAL BAYAR :%d",total_bayar);
printf("\n\n");
cout<<"\t\t\tINGIN INPUT LAGI [Y/T]:";cin>>lagi;
if(lagi=='y'||lagi=='Y')
goto awal;
getch();
}
#include<conio.h>
#include<iostream.h>
#include<iomanip.h>
#include<string.h>
main()
{
char nm_pesawat[20],kd_pesawat[20],lagi;
int kls_pesawat,hrg_tiket,jml_tiket,total_bayar;
awal:
clrscr();
cout<<"\t\t\t\t PROGRAM BY TRY PW "<<endl;
cout<<endl<<endl;
cout<<"\t\t\t\tPROGRAM TIKET PESAWAT"<<endl;
cout<<"\t\t\t\tJAKARTA - MALAYSIA"<<endl;
cout<<"--------------------------------------------------------------------------------"<<endl;
cout<<"Masukan Kode Pesawat [MPT/GRD/BTV] :";gets(kd_pesawat);
cout<<"\nKelas Pesawat:"<<endl;
cout<<"\t 1. Executive"<<endl;
cout<<"\t 2. Bisnis"<<endl;
cout<<"\t 3. Ekonomis"<<endl;
cout<<"Pilih Kelas [1/2/3]:";cin>>kls_pesawat;
if(strcmp(kd_pesawat,"MPT")==0)
{
strcpy(nm_pesawat,"MERPATI");
if(kls_pesawat==1)
(hrg_tiket=1500000);
else if(kls_pesawat==2)
(hrg_tiket=900000);
else if(kls_pesawat==3)
(hrg_tiket=500000);
else(hrg_tiket=0);
}
else if(strcmp(kd_pesawat,"GRD")==0)
{
strcpy(nm_pesawat,"GARUDA");
if(kls_pesawat==1)
(hrg_tiket=1200000);
else if(kls_pesawat==2)
(hrg_tiket=800000);
else if(kls_pesawat==3)
(hrg_tiket=400000);
else(hrg_tiket=0);
}
else if(strcmp(kd_pesawat,"BTV")==0)
{
strcpy(nm_pesawat,"BATAVIA");
if(kls_pesawat==1)
(hrg_tiket=1000000);
else if(kls_pesawat==2)
(hrg_tiket=700000);
else if(kls_pesawat==3)
(hrg_tiket=300000);
else(hrg_tiket=0);
}
printf("\n");
printf("\NAMA PESAWAT :%s",nm_pesawat);
printf("\nHARGA TIKET :%d",hrg_tiket);
printf("\n");
cout<<"JUMLAH TIKET :",cin>>jml_tiket;
total_bayar=hrg_tiket*jml_tiket;
printf("TOTAL BAYAR :%d",total_bayar);
printf("\n\n");
cout<<"\t\t\tINGIN INPUT LAGI [Y/T]:";cin>>lagi;
if(lagi=='y'||lagi=='Y')
goto awal;
getch();
}