program menghitung laba dan rugi...ok langsung aj...
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<iomanip.h>
void main()
{
int a;
struct produk
{
char nama[100];
int total,untung,hb,hj,satuan;
};
produk pdk[10];
for (a=1;a<=2;a++)
{
cout<<"Nama\t\t: ";cin>>pdk[a].nama;
cout<<"Harga Beli\t: ";cin>>pdk[a].hb;
cout<<"Harga Jual\t: ";cin>>pdk[a].hj;
cout<<"Satuan\t\t: ";cin>>pdk[a].satuan;
cout<<endl;
pdk[a].untung=((pdk[a].hj-pdk[a].hb)*pdk[a].satuan);
pdk[a].total=pdk[a].untung;
}
cout<<endl;
for (a=1;a<=2;a++)
{
cout<<endl;
cout<<"Nama\t\t: "<<pdk[a].nama;
cout<<endl;
cout<<"Harga Beli\t: "<<pdk[a].hb;
cout<<endl;
cout<<"Harga Jual\t: "<<pdk[a].hj;
cout<<endl;
cout<<"Satuan\t\t: "<<pdk[a].satuan;
cout<<endl;
cout<<"Keuntungan\t: "<<pdk[a].untung;
cout<<endl;
}
cout<<"total = "<<pdk[a].total;
getch();
}
No comments:
Post a Comment