Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 #include using namespace std; struct node_onwer { int price_of_car; string car_company,car_Model; node_onwer *nextlink, *prelink; }; node_onwer *head; void input(node_onwer *node) { cout << "Enter the name of Car Company :"; cin >> node->car_company; cout << "Enter the name of Car Model :"; cin >> node->car_Model; cout << "Enter the price of Car :"; cin >> node->price_of_car;

} 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<num<<" "<model<<" "<color<<" "<price<next; } } void swap(node_onwer *a, node_onwer *b) { int temp = a->price_of_car; a->price_of_car = b->price_of_car; b->price_of_car = temp; }

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:"<car_company<<" "<car_Model<<" "<price_of_car; return; } else{ temp=temp->nextlink; check=0; } } if(check==0) cout<<" This car is not available."; } int main() { int Choice_of_menu, Choice_of_sub_menu; node_onwer *currnet_for_pro; currnet_for_pro = new node_onwer(); head = NULL; if(head==NULL) { cout << "How namy car companies you have:"; cin >> Choice_of_menu; new_node(NULL); currnet_for_pro=head; for (int i = 0; i < Choice_of_menu; i++) { new_node(currnet_for_pro); currnet_for_pro = currnet_for_pro->nextlink; } } start_menu: cout << " \t\tMenue\t\t "; cout << "\t1.Owner case \t2.User case \t3.Exit"; cin >> Choice_of_menu; switch (Choice_of_menu) { case 1: st_owner_std:cout << "Owner Phase 1.Display all record 2.Change the record 3.serach any model 4.sort all record Back "; cin >> Choice_of_sub_menu; switch (Choice_of_sub_menu) { case 1: currnet_for_pro = head; while (currnet_for_pro !=NULL) { display_owner_node(currnet_for_pro); currnet_for_pro = currnet_for_pro->nextlink; } break; case 2: break; case 3: break; case 4: goto start_menu; default: goto st_owner_std; break; } break; case 2: int choices = 1; cout<<"Welcome To Honda's Showroom!"<

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

More Books

Students also viewed these Databases questions

Question

What are the current HRM challenges in the textile industry?

Answered: 1 week ago