|
hi there
i'm new to c++ and i hv been trying to make a little program
about adding vehicle details(ID,number,category, brand,price etc.) to a menu and displaying entered details,searching for a particular vehicle based on either vehicle number or category and deleting a record of sold vehicle.
following is the answer i could come up with
#include <iostream>
#include <string>
using namespace std;
struct vehicles
{
char vehicalid[8];
char vehicalnumber[8];
char category[10];
char brand[20];
int price;
} data[100];
int main ()
{
int d=0;
int i=0;
int op=0;
int n=0;
int b=0;
char num[8];
cout<<"option (1) add vehicle details \n";
cout<<"option (2) view view details \n";
cout<<"option (3) search for a vehicle \n";
cout<<"option (4) delete vehicle details \n"<<endl;
cout<<"option 01 \n"<<endl;
cout<<"enter your Option \n";
cin>>op;
loop:
while (op==1){
cout<<"enter vehicle ID \t";
cin>>data[n].vehicalid;
cout<<"enter vehicle number \t";
cin>>data[n].vehicalnumber ;
cout<<"enter vehicle category \t";
cin>>data[n].category;
cout<<"enter brand of the vehicle \t";
cin>>data[n].brand;
cout<<"enter price of the vehicle \t";
cin>>data[n].price;
n++;
cout<<"Enter Your Option to continue \t";
cin>>op;
if(op!=1)goto loop;
}
while (op==2){
cout<<"Option (2) \n";
while(b<n){
cout<<data.vehicalid<<'\t'<<data.vehicalnumber<<'\t'<<'\t'<<data.category<<'\t'<<data.brand <<'\t'<<data.price<<endl;
b++;
}
cout<<"Enter your option to continue \t";
cin>>op;
if(op!=2)goto loop;
}
while (op==3){
cout<<"Option (3) \n";
cout<<"enter vehicle number \n";
cin>>num;
while (i<n){
i++;
if(strcmp(data.vehicalnumber, num)==0) break;
}
cout<<"search resutl !! \n";
cout<<"vehicle id\t"<<"Number\t"<<"Category\t"<<"Brand\t"<<"price\n";
cout<<data.vehicalid<<'\t'<<data.vehicalnumber<<'\t'<<data.category<<'\t'<<data.brand<<'\t'<<data.price<<'\n';
cout<<"Enter your option to continue \t";
cin>>op;
if(op!=3)goto loop;
}
return 0;
}
i dont hv any idea how to delete details of a particular vehicle
and when first add vehicle details and go on to the second option to show detail it works fine but again if i try to add details of a vehicle and to see the details of all vehicle entered so far ,only latest details entered is shown
if someone can help me on this that would be really helpful
|
|
|
|
|
|
|
|