Discrete
Discrete
Project Code:
#include<iostream>
#include<conio.h>
#include<string.h>
string data;
struct BikeSelling {
string OwnerName;
int phone_no;
int model_no;
int chase_no;
BikeSelling *next;
};
class bikes{
private:
BikeSelling *head,*tail;
public:
bikes()
head=tail=NULL;
void projectname(){
cout<<endl;
cout<<endl;
cout<<endl;
void addBikeDetails()
string OwnerName;
cin>>OwnerName;
double phone_no;
cin>>phone_no;
cin>>model_no;
double chase_no;
cin>>chase_no;
tmp->OwnerName=OwnerName;
tmp->phone_no=phone_no;
tmp->model_no=model_no;
tmp->chase_no=chase_no;
tmp->next=NULL;
if(head==NULL)
head=tail=tmp;
else
tail->next=tmp;
tail=tail->next;
}}
void search()
BikeSelling *prev=NULL;
BikeSelling *current=NULL;
int chase_no;
cin>>chase_no;
prev=head;
current=head;
while(current->chase_no!=chase_no)
prev=current;
current=current->next;
cout<<current->OwnerName;
cout<<"\nPhone No:"<<endl;
cout<<current->phone_no;
cout<<"\nModel No of Bike:"<<endl;
cout<<current->model_no;
cout<<"\nChassis No:"<<endl;
cout<<current->chase_no;
getch();
}
void show(){
cout<<"_______________________________________________________________________
________";
cout<<"\n";
cout<<"\n";
cout<<"-------------------------------------------------------------------------------";
BikeSelling *temp;
temp = tail;
while(temp != NULL){
cout<<"\n";
cout<<"|\t"<<temp->OwnerName<<"\t|\t"<<temp->phone_no<<"\t|\t"<<temp-
>model_no<<"\t|\t"<<temp->chase_no<<"\t\t";
cout<<"\n";
cout<<"-----------------------------------------------------------------\n";
temp = temp->next ;
cout<<endl;
}}
};
int main()
system("color 4E");
bikes b;
int n;
do{
b.projectname();
cin>>n;
if(n==1)
b.addBikeDetails();
else if(n==2)
b.show();
else if(n==3)
b.search();
else if(n==4)
{
exit(0);
else
while(n!=4);
}
Output: