Sabtu, 30 Oktober 2010

Belajar c++ dasar


Buat teman2 di MI yang lupa nyatet nih aku postingin contoh
switch case if.

contoh input


contoh output



nih scriptnya..

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

main()
{
char kodeker,kodelas,*nama,*tujuan,*kls;
int total,jumlah,harga;

clrscr();

cout<<"\nMasukkan Kode Kereta :";cin>>kodeker;
cout<<"\nMasukkan Kode Kelas :";cin>>kodelas;
cout<<"\nJumlah Tiket yang di beli :";cin>>jumlah;
switch (kodeker)
{
case 'A':
nama="Argo Bromo";
tujuan="jkt - bdg";
if (kodelas=='1')
{
kls="Eksekutif";
harga=150000;
}
else if (kodelas=='2')
{
kls="Bisnis";
harga=90000;
}
else if (kodelas=='3')
{
kls="Ekonomi";
harga=50000;
}
break ;
case 'B':
nama="Senja Utama";
tujuan="jkt - jogja";
if (kodelas=='1')
{
kls="Eksekutif";
harga=300000;
}
else if (kodelas=='2')
{
kls="Bisnis";
harga=175000;
}
else if (kodelas=='3')
{
kls="Ekonomi";
harga=70000;
}
break;
}
clrscr();
cout<<"\n**********************************";
cout<<"\t\n PENJUALAN TIKET KERETA API";
cout<<"\n**********************************";
cout<<"\nNama Kereta :"<<nama;
cout<<"\nTujuan :"<<tujuan;
cout<<"\nKelas :"<<kls;

total=harga*jumlah;

cout<<"\nTotal Bayar :"<<total;
cout<<"\t\n************** TERIMA KASIH******** ";

getch () ;
}

hehehehe..mari belajar bersama..




1 komentar: