50% found this document useful (2 votes)
2K views3 pages

Car Sales C++ Project

This C++ program allows a user to purchase a car and calculates the discounted rate. It includes a Car class with methods to input customer details, calculate the discounted rate based on the car selected, and display the purchase details. The main function gets the number of entries, calls the input and rate calculation methods in a loop to write the data to a binary file, then calls the display method in another loop to output the purchase details to a separate file.

Uploaded by

Kenny Fernando
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
50% found this document useful (2 votes)
2K views3 pages

Car Sales C++ Project

This C++ program allows a user to purchase a car and calculates the discounted rate. It includes a Car class with methods to input customer details, calculate the discounted rate based on the car selected, and display the purchase details. The main function gets the number of entries, calls the input and rate calculation methods in a loop to write the data to a binary file, then calls the display method in another loop to output the purchase details to a separate file.

Uploaded by

Kenny Fernando
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

#include<iostream.

h>
#include<conio.h>
#include<stdio.h>
#include<fstream.h>
#include<stdlib.h>
class Car
{
char cname[50];
int carno;
int carrate;
int orgrate;
int lino;
char modep[50];
public:
void input()
{
cout<<"HI CUSTOMER!\nYour id number:";
cin>>lino;
cout<<"Enter your NAME:";
gets(cname);
cout<<"Enter the type of the car you would like to purchase:";
cout<<"1.SWIFT 2.CAMRY 3.A-STAR 4.BMW 5.AMAZE 6.INDICA";
cin>>carno;
cout<<"Enter mode of payment:";
gets(modep);
}
void ratecalc()
{
if(carno==1)
{
orgrate=1500000;
carrate=1500000-((15*1500000)/100);
}
else if(carno==2)
{
orgrate=1000000;
carrate=1000000-((10*1000000)/100);
}
else if(carno==3)
{
orgrate=2000000;
carrate=2000000-((18*2000000)/100);
}
else if(carno==4)
{
orgrate=700000;
carrate=700000-((8*700000)/100);
}
else if(carno==5)
{
orgrate=1200000;
carrate=1200000-((9*1200000)/100);
}
else if(carno==6)
{
orgrate=2500000;
carrate=2500000-((20*2500000)/100);
}

else
{
cout<<"Invalid choice";
}
}
void display()
{
cout<<"Customer Name:-"<<cname;
cout<<"ID no:-"<<lino;
cout<<"Car chosen:-"<<carno;
cout<<"mode of payment:"<<modep;
cout<<"Original Rate:-"<<orgrate;
cout<<"Discounted Rate:"<<carrate;
cout<<"HAPPY DRIVING";
}
}s;
void main()
{
clrscr();
int n;
ofstream carsale("CarSalesSystem.dat",ios::binary);
if(!carsale)
{
cout<<"error";
}
else
{
{
cout<<"Enter no of entries you would like to give:";
cin>>n;
for(int i=1;i<=n;i++)
{
s.input();
carsale.write((char*) &s,sizeof(s));
s.ratecalc();
}
}
}
fstream carsal("BILL.dat",ios::binary|ios::in);
while(!carsal.eof())
{
for(int i=1;i<=n;i++)
{
s.display();
carsal.write((char*)&s,sizeof(s));
}
}
carsale.close();
carsal.close();
getch();
}

You might also like