Berikut adalah program untuk penginputan pemesanan motor di sebuah dealer dengan menggunakan Dev C++
Source code:
#include<stdio.h>
#include<conio.h>
#include<iostream>
#include<iomanip>
#include<windows.h>
using namespace std;
void gotoxy(int x, int y)
{
COORD coord;
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
struct
{
char kd[5],*merk;
int hrg,jml,total;
}motor[30];
int main()
{
char nmsales[20],nm[20],lagi;
float tb=0;
int i,j;
awal:
gotoxy(17,1);
cout<<"IBM MOTOR"<<endl;
cout<<"Jl. Jend Ahmad Yani No. 38 Telp. 021-123.000.80.1"<<endl;
cout<<"=============================================="<<endl;
cout<<" Nama Sales : ";cin>>nmsales;
cout<<" Nama Pembeli : ";cin>>nm;
cout<<" Jumlah data : ";cin>>j;
for(i=1;i<=j;i++)
{
cout<<" \n Data ke- "<<i<<endl;
cout<<" Kode [SPR/VRO/TGR] : ";cin>>motor[i].kd;
if(strcmp(motor[i].kd,"SPR")==0|| strcmp(motor[i].kd,"spr")==0)
{
motor[i].merk="Supra X";
motor[i].hrg=16540000;
}
else if(strcmp(motor[i].kd,"VRO")==0|| strcmp(motor[i].kd,"vro")==0)
{
motor[i].merk="Vario Techno";
motor[i].hrg=15790000;
}
else if(strcmp(motor[i].kd,"TGR")==0|| strcmp(motor[i].kd,"tgr")==0)
{
motor[i].merk="Tiger";
motor[i].hrg=24940000;
}
else
{
cout<<" Anda Salah Memasukkan Kode . . !!!, input Kode[SPR/VRO/TGR] . ."<<endl;
cout<<" Ingin Input Lagi : ";cin>>lagi;
if(lagi=='Y'||lagi=='y')
goto awal;
else
goto akhir;
}
cout<<" Masukan Jumlah Beli : ";cin>>motor[i].jml;
motor[i].total=motor[i].hrg*motor[i].jml;
tb=motor[i].total+tb;
}
gotoxy(23,1);
cout<<"IBM MOTOR"<<endl;
gotoxy(8,2);
cout<<"Jl. Jend Ahmad Yani No. 38 Telp. 021-123.000.80.1"<<endl;
gotoxy(8,3);
cout<<"======================================================"<<endl;
cout<<"Nama Sales :"<<nmsales<<endl;
cout<<"Nama Pembeli :"<<nm<<endl;
cout<<"======================================================"<<endl;
cout<<"No. Kode Merk Harga Jumlah Total "<<endl;
cout<<" Motor Motor Beli "<<endl;
cout<<"======================================================"<<endl;
for(i=1;i<=j;i++)
{
cout<<setiosflags(ios::left)<<setw(5)<<i;
cout<<setiosflags(ios::left)<<setw(6)<<motor[i].kd;
cout<<setiosflags(ios::left)<<setw(12)<<motor[i].merk;
cout<<setiosflags(ios::left)<<setw(14)<<motor[i].hrg;
cout<<setiosflags(ios::left)<<setw(10)<<motor[i].jml;
cout<<setiosflags(ios::left)<<setw(2)<<motor[i].total<<endl;
}
cout<<"======================================================="<<endl;
printf(" Total bayar Rp. %4.0f",tb);
cout<<endl;
cout<<"Mau Input data lagi[Y/T]:";cin>>lagi;
if (lagi=='Y'||lagi=='y')
goto awal;
else
goto akhir;
akhir:
getch();
}
Output:
Tidak ada komentar:
Posting Komentar