0% found this document useful (0 votes)
59 views

Nama: Jeffry Alexsander Kelas: 2KA40 NPM: 15114616

This document contains source code for a C++ program that calculates rental fees for cars. The program allows the user to input details for multiple rentals, including customer name, car details, rental duration, and number of cars. It then displays a table with the rental details and calculates the total price. The program uses functions, arrays, structures, and loops to process the rental data and output the results.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views

Nama: Jeffry Alexsander Kelas: 2KA40 NPM: 15114616

This document contains source code for a C++ program that calculates rental fees for cars. The program allows the user to input details for multiple rentals, including customer name, car details, rental duration, and number of cars. It then displays a table with the rental details and calculates the total price. The program uses functions, arrays, structures, and loops to process the rental data and output the results.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Nama : Jeffry Alexsander

Kelas : 2KA40
NPM

: 15114616

1. Membuat Program C++ dengan Semua Statement Terutama


Array, Structure, dan Fungsi
Laporan Rental Sewa Mobil Alexsander
Output

Input:

Source Code

#include<conio.h>
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include <cstring>
using namespace std;
int totalh(int hrg,int jm);
float totalb(float ts,int th);
main()
{
struct
{char nm[10],jwb;
float ts;
}sewa;

char wkt[10],np[10][30],km[10],nm[10][25];
int i,n,jm[10],hrg[10],th[10];
atas:
system("cls");
cout<<"\tRental Mobil Alexsander "<<endl;
cout<<"*************************************"<<endl;
cout<<endl;
cout<<"Jumlah data penyewa : ";cin>>n;
cout<<endl;
for(i=1;i<=n;i++)
{
cout<<"sewa ke-"<<i<<endl;
cout<<"Masukan Nama Penyewa
= ";fflush(stdin);gets(np[i]);
cout<<"Kode mobil [01/02/03/04] = ";cin>>km;
cout<<"Waktu sewa [P/S/M]
= ";cin>>wkt[i];
cout<<"Jumlah mobil
= ";cin>>jm[i];
cout<<endl;
if(!strcmp(km,"01"))
{strcpy(nm[i],"AVANZA");
if(wkt[i]=='P'||wkt[i]=='p')
hrg[i]=400000;
else if(wkt[i]=='S'||wkt[i]=='s')
hrg[i]=350000;
else
hrg[i]=300000;
}
else if(!strcmp(km,"02"))
{strcpy(nm[i],"INNOVA");
if(wkt[i]=='P'||wkt[i]=='p')
hrg[i]=450000;
else if(wkt[i]=='S'||wkt[i]=='s')
hrg[i]=400000;
else
hrg[i]=350000;
}
else if(!strcmp(km,"03"))
{strcpy(nm[i],"Grand Livina");
if(wkt[i]=='P'||wkt[i]=='p')
hrg[i]=425000;
else if(wkt[i]=='S'||wkt[i]=='s')
hrg[i]=400000;
else
hrg[i]=350000;
}
else
{strcpy(nm[i],"APV");
if(wkt[i]=='P'||wkt[i]=='p')

hrg[i]=400000;
else if(wkt[i]=='S'||wkt[i]=='s')
hrg[i]=350000;
else
hrg[i]=300000;
}
th[i]=hrg[i]*jm[i];
}
system("cls");
cout<<"\t\t\t\tRental Mobil Alexsander"<<endl;
cout<<"*********************************************************************
*********"<<endl;
cout<<endl;
cout<<"_____________________________________________________________________
___________"<<endl;
cout<<" No. Nama Penyewa Nama Mobil Waktu Sewa Harga Jumlah
Mobil TotalHarga "<<endl;
cout<<"_____________________________________________________________________
___________"<<endl;
for(i=1;i<=n;i++)
{
cout<<" "<<setiosflags(ios::left)<<setw(6)<<i;
cout<<setiosflags(ios::left)<<setw(15)<<np[i];
cout<<setiosflags(ios::left)<<setw(15)<<nm[i];
cout<<setiosflags(ios::left)<<setw(9)<<wkt[i];
cout<<setiosflags(ios::left)<<setw(13)<<hrg[i];
cout<<setiosflags(ios::left)<<setw(11)<<jm[i];
cout<<setiosflags(ios::left)<<setw(5)<<th[i]<<endl;
sewa.ts=totalb(sewa.ts,th[i]) ;
}
cout<<"\n-----------------------------------------------------------------------------"<<endl;
printf("\t\t\t\t\t\tTotal Bayar
= Rp.%8.0f",sewa.ts);
cout<<endl<<endl;
cout<<"Input Lagi [Y/T] =";cin>>sewa.jwb;
if(sewa.jwb=='Y'||sewa.jwb=='y')
goto atas;
else
return 0;
}
int totalh(int hrg,int jm)
{
return(hrg*jm);
}
float totalb(float ts,int th)
{
return(ts+th);
}

You might also like