Question
C++ help, so I have the following code for Car Showroom project and I can't seem to fix the errors #include #include using namespace std;
C++ help, so I have the following code for Car Showroom project and I can't seem to fix the errors
#include
} void display_owner_node(node_onwer *temp) { cout << "Car Company is " << temp->car_company << endl; cout << "Car model is " << temp->car_Model << endl; cout << "Car price is " << temp->price_of_car << endl; }
void new_node(node_onwer *current_node) { node_onwer* temp1; temp1 = new node_onwer(); input(temp1); if (current_node==NULL) { head = new node_onwer(); temp1->prelink = NULL; temp1->nextlink = NULL; head->car_company = temp1->car_company; head->car_Model = temp1->car_Model; head->price_of_car = temp1->price_of_car; } else { current_node->nextlink = temp1; temp1->prelink = current_node; temp1->nextlink = NULL; } }
node_onwer* Serach_owner_node(string model_of_car, node_onwer* head) { node_onwer* current = head; while (current != NULL) { if (current->car_Model == model_of_car) { cout << "The Company of the is " << current->car_company << endl; cout << "The Model of the is " << current->car_Model << endl; cout << "The Price of the is " << current->price_of_car << endl; return current; } current = current->nextlink; } cout<<"This car is not available "; return NULL; }
void swap_of_node_owner(node_onwer *one_node,node_onwer *second_node) { string model_of_car,Company_of_car; int price_of_car;
Company_of_car=one_node->car_company ; model_of_car = one_node->car_Model; price_of_car = one_node->price_of_car;
one_node->car_company = second_node->car_company; one_node->car_Model = second_node->car_Model; one_node->price_of_car = second_node->price_of_car;
second_node->car_company = Company_of_car; second_node->car_Model = model_of_car; second_node->price_of_car = price_of_car; }
void sort_of_node_owner(node_onwer *head)//Issue sorting using string[0] { node_onwer* current ,*current1; current = new node_onwer(); current1 = new node_onwer(); current = head; while (current != NULL) { current1 = head; while (current1 != NULL) { if ((current->car_company) > (current1->car_company)) { swap_of_node_owner(current, current1); } current1 = current1->nextlink; } current = current->nextlink; } } void insertion_node_owner(node_onwer *head) { node_onwer *temp, * current; current = new node_onwer(); temp =new node_onwer(); current = head; while (current != NULL) { temp = current; current = current->nextlink; } new_node(temp); sort_of_node_owner(head); }
void delete_node_owner_model(string Model) { node_onwer* temp; temp=new node_onwer();
node_onwer* current; current = new node_onwer(); int a = 0; current = head; while (current == NULL) { if (current->car_Model == Model) { temp = current; break; a = 1; } else current = current->nextlink; } if(a==1){ temp = new node_onwer(); if (temp == head) { temp->nextlink = NULL; delete(temp); } else if (temp->nextlink == NULL) { temp->prelink = NULL; delete(temp); } else { node_onwer* temp1; temp = new node_onwer(); temp1 = temp->prelink; temp1->nextlink = temp->nextlink; temp = temp->nextlink; temp->prelink = temp1; temp = temp->prelink; delete(temp); } } } struct node { int num; string model,color; int price; node* next=NULL; node* prev=NULL; }; node* Head=NULL; void insert(int a,string b,string c,int d) { struct node* newnode = new node(); newnode->num = a; newnode->model=b; newnode->color=c; newnode->price=d; newnode->prev = NULL; newnode->next = Head; if(head != NULL) Head->prev = newnode ; Head = newnode; } void display() { node* p=Head; while(p!=NULL) { cout<
void bubbleSort(node_onwer *start) { int swapped; node_onwer *ptr1; node_onwer *lptr = NULL; /* Checking for empty list */ if (start == NULL) return; do { swapped = 0; ptr1 = start; while (ptr1->nextlink != lptr) { if (ptr1->price_of_car > ptr1->nextlink->price_of_car) { swap(ptr1, ptr1->nextlink); swapped = 1; } ptr1 = ptr1->nextlink; } lptr = ptr1; } while (swapped); }void search(string x) { int check; node_onwer* temp=head; while(temp!=NULL) { if(temp->car_Model==x) { cout<<"These are the Details of the car:"< bubbleSort(head); display(); while(choices != 0) { string car_name; cout<<" What Car are you looking for:"; cin>>car_name; search(car_name); cout<<" Do you want to Check for some other Car?(1 for yes, 0 to exit)"; cin>>choices; } break; case 3: break; I want to call the bubbleSort, search and delete functions inside the main, and also can't seem to fix the errors caused by goto statement and choices
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started