63 800
Assignments Done
99,5%
Successfully Done
In August 2018

Answer to Question #29607 in C++ for meme

Question #29607
Design a C++ application using Linked List to store car information for a Used Car Dealer. Your application must be able to do the following

1. Add new car information to the store. The car information must contains the following
•Model (e,g. Camry, Accord, Focus)
•Manufacturer (e.g. Toyota, Honda, Volkswagen)
•Year(e.g 1997, 2000)
•Registration No / Car Plate No (e.g. ABC231)
•Selling Price (e.g. 20000, 15000)

2. Delete car information from the store
Expert's answer
//Design a C++ application using Linked List to store car information for a Used Car Dealer.
//Your application must be able to do the following
//
//1. Add new car information to the store. The car information must contains
//the following •Model (e,g. Camry, Accord, Focus) •Manufacturer
//(e.g. Toyota, Honda, Volkswagen) •Year(e.g 1997, 2000) •Registration No /
// Car Plate No (e.g. ABC231) •Selling Price (e.g. 20000, 15000)
//
//2. Delete car information from the store

#include <iostream>
#include <string>
#include <list>
using namespace std;

class car{
public:
string model;
string manufacturer;
int year;
int no;
string carNo;
double price;
public:
car(){}
//car(car &c){ *this& = c;}

void print(){
cout<<"model : "<<model<<endl;
cout<<"manufacturer : "<<manufacturer<<endl;
cout<<"year : "<<year<<endl;
cout<<"Registration no : "<<no<<endl;
cout<<"carNo : "<<carNo<<endl;
cout<<"price : "<<price<<endl;
}

void add(){
cout<<"model : ";cin>>model;
cout<<"manufacturer : ";cin>>manufacturer;
cout<<"year : ";cin>>year;
cout<<"Registration no : ";cin>>no;
cout<<"carNo : ";cin>>carNo;
cout<<"price : ";cin>>price;
}
friend struct node;
};

struct node{
car c;
node *next;
};

/*class list{
protected:
node *head;
public:

list() { head = NULL;}
~list(){
node* ptr = head;
node* ptrOld = head;

if (ptr!=NULL){
ptrOld=ptr;
delete ptrOld;
ptr = ptr->next ;
}

}
void add(){
car mc;
mc.add();

node* ptr = head;

node *newCar = new node;
newCar->c = mc;

if (head == NULL){
head = newCar;
head->next=NULL;
return;
}

if (ptr != NULL){
ptr = ptr->next ;
}



ptr = newCar;
ptr->next=NULL;
//ptr = newCar;
}
void show(){
node* ptr = head;
node* ptrOld = head;

if (ptr == NULL) {cout<<"!!\n";return;}

if (ptr->next != NULL){
ptrOld = ptr;
ptr = ptr->next ;
}

ptr->c.print();

delete ptr;
ptrOld->next = NULL;
}
};*/

int main(){
list <car> l;
car c;
c.add();
l.push_back(c);
l.back().print();
l.pop_back();

system("PAUSE");
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions