i need help for my task please :(

#include<conio.h>
#include<iostream.h>
#include<iomanip.h>
main()
{
int banyak,i,tobs=0,topemb=0,tanggal,kode[20],lama[20],
total[20],pajak[20],harga[20];
float diskon;
char nama[20],jenis[20][10];
cout<<"Jumlah Sewa :";cin>>banyak;
cout<<"Nama Penyewa :";cin>>nama;
cout<<"Tanggal Sewa :";cin>>tanggal;
cout<<endl;
for(i=1;i<=banyak;i++)
{
cout<<" Input Data Sewa "<<endl;
cout<<"-----------------------"<<endl;
cout<<"Data Penyewaan ke- :"<<i<<endl;
cout<<"Kode Mobil [1/2/3] :";cin>>kode[i];
cout<<"Lama Pinjam :";cin>>lama[i];
cout<<endl;
if(kode[i]==1)
{strcpy(jenis[i],"Sedan");harga[i]=450000;
pajak[i]=100000;
}
else if(kode[i]==2)
{strcpy(jenis[i],"Minibus");harga[i]=700000;
pajak[i]=150000; }
else
{strcpy(jenis[i],"Bus");harga[i]=1000000;
pajak[i]=200000;
}
if(lama[i]>20)
{diskon=0.1*tobs;}
else
{diskon=0;}
total[i]=lama[i]*harga[i]+pajak[i];
tobs+=total[i];
topemb=tobs-diskon;
}
cout<<"\tDaftar Penyewaan Mobil \n"<<endl;
cout<<"\tPT SAFETY TRANSPORTATION \n\n"<<endl;
cout<<endl<<endl;
cout<<"Nama Penyewa:"<<nama;
cout<<"\t\t\t\tTanggal Sewa :"<<tanggal<<endl;
cout<<"==========================================================";
cout<<"============="<<endl;
cout<<"No Kode Mobil Jenis Mobil Lama Sewa Harga ";
cout<<"Pajak Total"<<endl;
cout<<"==========================================================";
cout<<"============="<<endl;
for(i=1;i<=banyak;i++)
{
cout<<setiosflags(ios::left)<<setw(8)<<i;
cout<<setiosflags(ios::left)<<setw(10)<<kode[i];
cout<<setiosflags(ios::left)<<setw(10)<<jenis[i];
cout<<setiosflags(ios::left)<<setw(12)<<lama[i];
cout<<setiosflags(ios::left)<<setw(10)<<harga[i];
cout<<setiosflags(ios::left)<<setw(10)<<pajak[i];
cout<<setiosflags(ios::left)<<setw(10)<<total[i];
cout<<endl;
}
cout<<"=========================================================";
cout<<"=============="<<endl;
cout<<"\t\t\tTotal Biaya Sewa :Rp."<<tobs<<endl;
cout<<"\t\t\tDiskon :Rp."<<diskon<<endl;
cout<<"\t\t\t\t\tTotal Pembayaran :Rp."<<topemb<<endl;
getch();
}

why the calculation of the discout does not appear? is there anything that is less than program listings?
Last edited on
I don't really see the reason why discount shouldn't show up. Even if there is no discount, it should at least show 0 on the screen. If you mean that discount shouldn't be 0,

1
2
3
4
if(lama[i]>20)
{diskon=0.1*tobs;}
else
{diskon=0;}


This is the only part where I really see you are changing discount. If there are less than 20 lama live at the house, discount is 0, of course.






I also see some problem in your code.

1
2
3
4
5
6
#include <iostream.h>
#include <iomanip.h>
// There is no such header file "iostream.h", "iomanip.h"
// I think what you want are "iostream", "iomanip"
#include <iostream>
#include <iomanip> 


1
2
3
4
main()
// main is function. Lines like above shouldn't be allowed... proper way to write main is:
int main( void )
// or int main( int argc, char** argv ) 


1
2
// cout, cin is in namespace "std". The proper way of using it should be
std::cout, std::cin.




Last edited on
Topic archived. No new replies allowed.