Upload
bagoes-dwi-harianto
View
48
Download
7
Embed Size (px)
Citation preview
#Program menghitung tarif wartel;
#include<iostream.h>#include<string.h>using namespace std;//structstruct Twartel
{
char nomorTujuan[12];
char chrPilihan;
int x,y,z,k,l,m,jumlah,bea;
};
const int maxWrl = 15;
int counter = 0;
int jum1,jum2;
Twartel wrl[maxWrl];
//function & procedurevoid loading ()//fungsi 1{for (int o = 0;o<=100;o+=1){cout<<endl<<”loading …”<<o<<”%”;system(“cls”);}}void Tarif(int n)//fungsi 2{if (wrl[n].chrPilihan== ‘a’){wrl[n].bea=wrl[n].jumlah*5;cout << “Waktu bicara anda adalah =”<<wrl[n].jumlahcout << “Biaya penggunaan telepon adalah = Rp “wrl[n].bea<<”,00″}else if(wrl[n].chrPilihan == ‘b’)
{
wrl[n].bea=wrl[n].jumlah*30;
cout << “Waktu bicara anda adalah =”
wrl[n].jumlahcout << “Biaya penggunaan telepon adalah = Rp “
wrl[n].bea<<”,00″
}else
{
cout << “masukkan anda salah” << endl;cout << “ulangi lagi” << endl;}}void cetakMenu()//fungsi 3
{
cout<<<”===========MeNu============\n”<<endl;
cout<<” 1. Isi data telpon “
cout<<” 2. Cetak data “
cout<<” 3. Keluar”<<endl;
cout<<”"<<endl;
cout<<”Masukan pilihan: “;
}void isiDataWrl (int n)//fungsi 4
{
int a,b,c,d,e,f,k,l,m,x,y,z;
//jam awal
cout<< “Masukkan nomor tujuan : “;
cin>>(wrl[n].nomorTujuan);
cout<<”jam awal: “;cin>>wrl[n].x;
cout<< ” Menit : “;
cin>>wrl[n].y;
cout<< ” Detik : “;
cin>>wrl[n].z;
a=wrl[n].x;
b=wrl[n].y;
c=wrl[n].z;
//do
//{
jum1= a*3600 + b *60 + c;//}while (a>23 && b>59 && c>59);//cout << “masukkan salah”
//jam akhir
cout<<< “jam akhir : “;
cin>>wrl[n].k;
cout<< “Menit : “;
cin>>wrl[n].l;
cout<< “Detik : “;
cin>>wrl[n].m;
d=wrl[n].k;
e=wrl[n].l;
f=wrl[n].m;
if(jum2<jum1){cout<<<”Jam Salah”<<endl;}else
{
cout<<< “Pilihan : ” <
cout << “a. Lokal” << endl;
cout << “b. Interlokal” << endl;
cout << “pilihan anda (huruf kecil) : “;
cin>>wrl[n].chrPilihan;wrl[n].jumlah=jum2-jum1;Tarif(n);}//do//{jum2= d*3600 + e *60 + f;wrl[n].jumlah=jum2-jum1;Tarif(n);
//}while ((a>23) && (b>59) && (c>59));
//cout << “masukkan salah”
getchar();
}void cetakDataTelpon()//fungsi 5
{
if (counter==0)
{
cout<<<”data masih kosong”<}else{for(int i=0;i
{
cout<<<”NO["<<i+1<<"]“<<”————–”;
cout<<<”Masukkan nomor Tujuan :
“<i].nomorTujuan
cout<<<”Pilihan : “<<
cout<<<”jam awal :
“<i].x<<”:”<<<”:”<cout<<<”jam akhir :
“<i].k<<”:”<<<”:”<<cout<<<”jumlah: “<<<endl;}getchar();}// main programint main(void)//fungsi 6 ( fungsi Utama){//local variabelint pilihan;
loading();
// main looping
cout<< “I=================================I”<<endl;
cout<< “I SeLaMaT daTanG di WaRteL TINITA I”
cout<< “I
I”<<endl;cout<<“I=================================I”<<<<endl;do
{
cetakMenu();
cin>>pilihan;
getchar();
switch(pilihan)
{
case 1 : cout<<< “—Isi data telpon–”
isiDataWrl(counter);
counter++;
break;
case 2 : cout<<< “—Cetak data—”<
cetakDataTelpon();
break;
case 3 : cout<<< “—Keluar dari program—
“<<endl;
cout<< “I=================================I”<<endl;
cout<< “I
TERIMA KASIHI”<<endl;cout<< “II”<<endl;cout<<”I=================================I”<<<<endl;10
cout<<endl<< ” Created BY: “<<endl;
cout<< “1. Tamara Dhagistami/08523016″
cout<< “2. Ratya Ayu Ningtyas/08523019″
cout<< “3. Yunita Dwi Ertanty/08523034″
break;defult : cout<<< “pilihan tidak ada”
}
}while (pilihan !=3); //end main loop
return 0;
}