# Latihan UTS

Gunakan Array
Total = Harga * Jumlah Beli
Total Bayar = Jumlah Keseluruhan Dari Pembelian
Logika if atau case

Kode
Produk

Nama Motor

H || h

Honda

Y || y

Yamaha

S || s

Suzuki

Ukuran
(CC)
110
125
225
110
125
225
110
125
225

Harga
130.000
140.000
150.000
100.000
110.000
120.000
80.000
90.000
100.000

Rancangan Input

Rancangan Ouput

Borland C++

Created By F@Y

Jawaban
#include <stdio>
#include <conio>
#include <iostream>
#include <iomanip>
main()
{
char
nmpet[25],nmpem[20][20],kd[20],*nm[20],ukuran[3][20],lagi;
double hrg[20],jb[20],tot[20],totbyr=0;
int i,j;
awal:
cout<<"
cout<<" Jl.Pancoran barat no 60 Telp 021 7568451"<<endl;
cout<<"==========================================="<<endl;
cout<<" Masukan Nama Petugas = ";cin>>nmpet;
cout<<" Masukan Jumlah Data = ";cin>>j;
cout<<endl;
for(i=1;i<=j;i++)
{
cout<<" Data Ke - "<<i<<endl;
cout<<" Masukan Nama Pembeli
= ";cin>>nmpem[i];
cout<<" Masukan Kode [H/Y/S]
= ";cin>>kd[i];
cout<<" Masukan CC [110/125/225] = ";cin>>ukuran[i];
if(kd[i]=='H' || kd[i]=='h')
{
nm[i]="HONDA";
if(strcmp(ukuran[i],"110")==0)
{
hrg[i]=130000;
}
else if(strcmp(ukuran[i],"125")==0)
{
hrg[i]=140000;
}
else
{
hrg[i]=150000;
}
}
else if(kd[i]=='Y' || kd[i]=='y')
{
nm[i]="YAMAHA";
if(strcmp(ukuran[i],"110")==0)
{
hrg[i]=100000;
}
else if(strcmp(ukuran[i],"125")==0)

Borland C++

Created By F@Y

{
hrg[i]=110000;
}
else
{
hrg[i]=120000;
}
}
else
{
nm[i]="SUZUKI";
if(strcmp(ukuran[i],"110")==0)
{
hrg[i]=80000;
}
else if(strcmp(ukuran[i],"125")==0)
{
hrg[i]=90000;
}
else
{
hrg[i]=100000;
}
}
cout<<" Nama Produk
cout<<" Harga
cout<<" Masukan Jumlah Beli
cout<<endl;
tot[i]=hrg[i]*jb[i];
totbyr=totbyr+tot[i];

= "<<nm[i]<<endl;
= "<<hrg[i]<<endl;
= ";cin>>jb[i];

}
clrscr();
cout<<"
cout<<"
Jl.Pancoran barat no 60 Telp 021
7568451"<<endl<<endl;
cout<<"Nama Petugas = "<<nmpet<<endl;
cout<<"============================================="<<endl;
cout<<"No Nama
Kode
Nama
Ukuran Harga
Jumlah
Total"<<endl;
cout<<"
Pembeli Produk
Produk (cc)
Beli"<<endl;
cout<<"============================================="<<endl;
for(i=1;i<=j;i++)
{
cout<<setiosflags(ios::left)<<setw(4)<<i;
cout<<setiosflags(ios::left)<<setw(9)<<nmpem[i];
cout<<setiosflags(ios::left)<<setw(9)<<kd[i];
cout<<setiosflags(ios::left)<<setw(9)<<nm[i];
cout<<setiosflags(ios::left)<<setw(7)<<ukuran[i];

Borland C++

Created By F@Y

cout<<setiosflags(ios::left)<<setw(10)<<hrg[i];
cout<<setiosflags(ios::left)<<setw(7)<<jb[i];
cout<<setiosflags(ios::left)<<setw(8)<<tot[i]<<endl;
}
cout<<"============================================="<<endl;
cout<<"Total Bayar = "<<totbyr<<endl<<endl;
cout<<"Mau Input Data Lagi[Y/T] = ";cin>>lagi;
if(lagi=='Y'||lagi=='y')
goto awal;
else
goto akhir;
akhir:
getch();
}

Borland C++

Created By F@Y