Contoh Soalnya (Fungsi Judul) :
========================
Departemen Penerbangan
========================
Kode Pesawat Jenis Pesawat Harga
1 Merpati 400.000
2 Garuda 500.000
• Gunakan fungsi judul.
Jawabannya :
#include "stdio.h"
#include "iostream.h"
#include "conio.h"
#include "iomanip.h"
judul()
{cout<<" ========================"((endl;
cout<<" Departemen Penerbangan"((endl;
cout<<" ========================"((endl;
}
main()
{
int i,jd,h[10];
char *j[10],jam[10][10],nama[10][10],kp[10][10];
judul();
cout<
cout<
// tanda << dan >> di ganti dengan tanda (( dan )) dikarenakan //
// tidak bisa tampil jika menggunkanan tanda << dan >> jadi //
// ganti aj nanti :) //
for (i=1;i<=jd;i++)
{cout<<"Data Ke-"((i((endl;
cout<<"Nama Penumpang : ";cin>>nama[i];
cout<<"Kode Pesawat : ";cin>>kp[i];
cout<<"Jam Keberangkatan : ";gets(jam[i]);
if (strcmp(kp[i],"1")==0)
{j[i]="Merpati";
h[i]=400000;
}
else
if (strcmp(kp[i],"2")==0)
{j[i]="Garuda";
h[i]=500000;
}
else
{j[i]="-";
h[i]=0;
}
cout<<"Jenis Pesawat : "((j[i]((endl;
cout<<"Harga : "((h[i]((endl;
cout<
cout((endl((endl;
judul();
cout((endl;
cout<<"-------------------------------------"((endl;
cout<<"No Nama Kode Jam Harga "((endl;
cout<<"-------------------------------------"((endl;
for (i=1;i<=jd;i++)
{cout((setiosflags(ios::left)((setw(4)((i;
cout((setiosflags(ios::left)((setw(7)((nama[i];
cout((setiosflags(ios::left)((setw(9)((kp[i];
cout((setiosflags(ios::left)((setw(9)((jam[i];
cout((setiosflags(ios::left)((setw(9)((h[i]((endl;
cout(("-------------------------------------"((endl;
}
getch();
}
Layar Outputnya :
0 komentar:
Posting Komentar