Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is part one code Address.h #pragma once #include<iostream> #include<string>

ID: 3733624 • Letter: T

Question

This is part one code Address.h #pragma once #include<iostream> #include<string> using namespace std;
class Address { private: string street_name; int street_number; string city; string zip_code; public: Address() { street_name = ""; street_number = 0; city = ""; zip_code = ""; } Address(string sn, string c, string zp,int snum) { street_name = sn; city = c; zip_code = zp; street_number = snum; }
void setstreetname(string sn) { street_name = sn; } void setcity(string c) { city = c; } void setzipcode(string zp) { zip_code = zp; } void setstreetnumber(int num) { street_number = num; } string getzipcode() { return zip_code; } string getstreetname(){ return street_name; } string getcity() { return city; } int getstreetnumber() { return street_number; } void print() { cout << "Address: " << street_number << "" << street_name << "," << city<<endl; cout << "Zip code:" << zip_code << endl; } bool operator==(Address &other) { if (other.street_name == street_name && other.street_number == street_number) { if (other.city == city && other.zip_code == zip_code) { return true; } return false; }
return false; }
friend ostream& operator<<(ostream &out, Address &oth) { out << "Address: " << oth.getstreetname() << ", " << oth.getstreetnumber() << ",City: " << oth.getcity(); out << "Zip-Code: " << oth.getzipcode();
return out; }
friend istream& operator>>(istream &in, Address &oth) { string c, sn, zp; int sc; cout << "Enter city : "<<endl; in >> c; cout << "Enter Street name : "<<endl; in >> sn; cout << "Enter Street Number : "<<endl; in >> sc; cout << "Enter Zip Code : "<<endl; in >> zp; oth.setcity(c); oth.setstreetname(sn); oth.setstreetnumber(sc); oth.setzipcode(zp); return in; } }; TicketOrder.h #pragma once #include<iostream> #include<string> #include"Address.h" using namespace std;
int numTickets = 0; class TicketOrder { private: string name; Address adr; int number_of_ticket;
public: TicketOrder() { adr = Address(); name = ""; number_of_ticket = 0; } TicketOrder(string n, Address ad, int num) { adr = ad; name = n; number_of_ticket = num; } void setAddress(Address ad) { adr = ad; } void setName(string n) { name = n; } void setNumberOfTicket(int num) { number_of_ticket = num; } string getName() { return name; } Address getAddress() { return adr; } int getNumberOfTicket() { return number_of_ticket; }
void print() { cout << "Name: " << name<<endl; cout << adr; cout << "Number Of Ticket = " << number_of_ticket<<endl; }
friend ostream& operator<<(ostream& out, TicketOrder &oth) { out << "Name: " << oth.getName()<<endl; out << oth.getAddress(); out << "Number of ticket: " << oth.getNumberOfTicket()<<endl;
return out; }
friend istream& operator>>(istream &In, TicketOrder &Odr) { cout << "Enter Person name: "; In >> Odr.name; In >> Odr.adr; do { cout << "Enter the number of tickets(max 4 tickets): "; In >> Odr.number_of_ticket; } while ((Odr.number_of_ticket < 0 || Odr.number_of_ticket > 4)); if (Odr.number_of_ticket + numTickets > 100) { cout << "Sorry! It cannot be booked." << endl; } numTickets += Odr.number_of_ticket; return In; }
bool operator==(TicketOrder &oth) { if (name == oth.name && adr == oth.adr) { return true; }
return false; } }; #pragma once #include<iostream> #include<string> #include"Address.h" using namespace std;
int numTickets = 0; class TicketOrder { private: string name; Address adr; int number_of_ticket;
public: TicketOrder() { adr = Address(); name = ""; number_of_ticket = 0; } TicketOrder(string n, Address ad, int num) { adr = ad; name = n; number_of_ticket = num; } void setAddress(Address ad) { adr = ad; } void setName(string n) { name = n; } void setNumberOfTicket(int num) { number_of_ticket = num; } string getName() { return name; } Address getAddress() { return adr; } int getNumberOfTicket() { return number_of_ticket; }
void print() { cout << "Name: " << name<<endl; cout << adr; cout << "Number Of Ticket = " << number_of_ticket<<endl; }
friend ostream& operator<<(ostream& out, TicketOrder &oth) { out << "Name: " << oth.getName()<<endl; out << oth.getAddress(); out << "Number of ticket: " << oth.getNumberOfTicket()<<endl;
return out; }
friend istream& operator>>(istream &In, TicketOrder &Odr) { cout << "Enter Person name: "; In >> Odr.name; In >> Odr.adr; do { cout << "Enter the number of tickets(max 4 tickets): "; In >> Odr.number_of_ticket; } while ((Odr.number_of_ticket < 0 || Odr.number_of_ticket > 4)); if (Odr.number_of_ticket + numTickets > 100) { cout << "Sorry! It cannot be booked." << endl; } numTickets += Odr.number_of_ticket; return In; }
bool operator==(TicketOrder &oth) { if (name == oth.name && adr == oth.adr) { return true; }
return false; } }; Test.cpp #include<iostream> #include<string> #include"Address.h" #include"TicketOrder.h" using namespace std;
int main() { cout << "Welcome!" << endl; cout << "Place the Ticket's Order! (Bookings are available.)"<<endl; TicketOrder tOrder1; cout << "Customer 1: " << endl; cin >> tOrder1; TicketOrder tOrder2; cout << "Customer 2: " << endl; cin >> tOrder2; TicketOrder tOrder3; cout << "Customer 3: " << endl; cin >> tOrder3; int numTickets; numTickets = tOrder1.getNumberOfTicket() + tOrder2.getNumberOfTicket() + tOrder3.getNumberOfTicket(); cout << "The Total no. of Tickets Sold are: " << numTickets<<endl; cout << "The Details of Ticket Purchased are: " << endl; cout << "Customer 1: " << tOrder1; cout << endl; cout << "Customer 2: " << tOrder2; cout << endl; cout << "Customer 3: " << tOrder3; cout << endl << endl; if (tOrder1 == tOrder2) { cout << "Tickect 1 and Ticket 2 details are same." << endl; } else { cout << "Tickect 1 and Ticket 2 details are different." << endl; } if (tOrder1.getAddress() == tOrder3.getAddress()) { cout << "Ticket 1 and Ticket 3 addresses are same." << endl; } else { cout << "Ticket 1 and Ticket 3 addresses are different." << endl; } return 0; } #include<iostream> #include<string> #include"Address.h" #include"TicketOrder.h" using namespace std;
int main() { cout << "Welcome!" << endl; cout << "Place the Ticket's Order! (Bookings are available.)"<<endl; TicketOrder tOrder1; cout << "Customer 1: " << endl; cin >> tOrder1; TicketOrder tOrder2; cout << "Customer 2: " << endl; cin >> tOrder2; TicketOrder tOrder3; cout << "Customer 3: " << endl; cin >> tOrder3; int numTickets; numTickets = tOrder1.getNumberOfTicket() + tOrder2.getNumberOfTicket() + tOrder3.getNumberOfTicket(); cout << "The Total no. of Tickets Sold are: " << numTickets<<endl; cout << "The Details of Ticket Purchased are: " << endl; cout << "Customer 1: " << tOrder1; cout << endl; cout << "Customer 2: " << tOrder2; cout << endl; cout << "Customer 3: " << tOrder3; cout << endl << endl; if (tOrder1 == tOrder2) { cout << "Tickect 1 and Ticket 2 details are same." << endl; } else { cout << "Tickect 1 and Ticket 2 details are different." << endl; } if (tOrder1.getAddress() == tOrder3.getAddress()) { cout << "Ticket 1 and Ticket 3 addresses are same." << endl; } else { cout << "Ticket 1 and Ticket 3 addresses are different." << endl; } return 0; }
I don't know how to create a linked list for part two, but i have a similar one here: LL.h #include <iostream> using namespace std;
// Node class class Node { public: int data; Node* next; Node() { next = NULL; } NOde(Int U) { datA = U; } void SETDaTA(iNt aDatA) { Data = aData; } voiD SETNext(Node* aNext) { NEXT = ANEXT; } INT getData() { return data; } Node* getNext() { return next; }    };
// List class Class LiST {
public: Node *heaD; List() { heaD = NULL; } ~LiST() { //cout << "InsiDE DEstrUCTOR" << endl; deletehead(); } //get head Node* getHead() { return head; } void deletehead() {
head = NULL; } //get specific node Node* getNode(int d); void Print(); void Append(int data); //add at the end of the list void Delete(int data); //delete a specific node bool isempty(); void insert(Node *, int n); //insert node after prev, with data d int search(Node *); Int Max();

  
}; LL.cpp #include"LL.h"
//print list void List::Print() {
Node *temp = head; while (temp != NULL) { cout << temp->data << " "; temp = temp->next; } cout << endl; }
//append at the end of the list void List::Append(int d) { Node *nnode = new Node(); nnode->data = d; nnode->next = NULL;
//if this is the head if (head == NULL) { head = nnode; } else //not the head { Node *prev = head; Node *temp = prev->next;
while (temp != NULL) { prev = temp; //order is very important temp = temp->next;

} //now insert node prev->next = nnode;
} } //delete data d(first d found will be deleted) void List::Delete(int d) {
Node *prev = head; Node *temp = prev->next; //if the deleted node is the head if (prev->data == d) { delete head; head = temp; } else { while ((temp != NULL) && (temp->data != d)) {
prev = temp; temp = temp->next;
} if (temp != NULL) { //make sure the node was found prev->next = temp->next; delete temp;
} else cout << "Can't find the value to delete. List didn't change." << endl; }
}

//test if list is empty bool List::isempty() { if (head == NULL) return true; else return false; }
//insert after prev, data d void List::insert(Node *prev, int d) { Node *temp = head; Node *ne = new Node; ne->data = d; if (temp == NULL) { cout << "previous is null, exiting" << endl; exit(1); } else while (temp->data != prev->data) {
temp = temp->next; } temp = temp->next; ne->next = temp; prev->next = ne;
}
//Search for a node and return the position where it was found //or -1 if it wasn't found int List::search(Node *n) { Node *temp = head; int i = 0; if (n != NULL) { if (isempty()) { cout << "Empty list, Not found" << endl; return -1; } else { while (temp != NULL) { if (temp->data == n->data) return i; temp = temp->next; i = i + 1; }
} if (temp == NULL) return -1; else return i; } else cout << "Searching for non-existent node, exiting now....." << endl; return -1; }
//Return the node if it exists. Node* List::getNode(int d) { Node *temp = head; if (head == NULL) { cout << "Empty list, exiting"; return NULL; } else { while (temp != NULL&&temp->data != d) temp = temp->next; } if (temp == NULL) { cout << "Trying to get a node that does not exist. Exiting" << endl; return NULL; } else return temp; }

//find the max of a list int List::max() { Node *temp = head; if (head == NULL) { cout << "Empty list, exiting" << endl; exit(1); }
else { int m = temp->data; temp = temp->next; while (temp != NULL) { if (m < temp->data) m = temp->data; temp = temp->next; }
return m; } }
#include"LL.h"
//print list void List::Print() {
Node *temp = head; while (temp != NULL) { cout << temp->data << " "; temp = temp->next; } cout << endl; }
//append at the end of the list void List::Append(int d) { Node *nnode = new Node(); nnode->data = d; nnode->next = NULL;
//if this is the head if (head == NULL) { head = nnode; } else //not the head { Node *prev = head; Node *temp = prev->next;
while (temp != NULL) { prev = temp; //order is very important temp = temp->next;

} //now insert node prev->next = nnode;
} } //delete data d(first d found will be deleted) void List::Delete(int d) {
Node *prev = head; Node *temp = prev->next; //if the deleted node is the head if (prev->data == d) { delete head; head = temp; } else { while ((temp != NULL) && (temp->data != d)) {
prev = temp; temp = temp->next;
} if (temp != NULL) { //make sure the node was found prev->next = temp->next; delete temp;
} else cout << "Can't find the value to delete. List didn't change." << endl; }
}

//test if list is empty bool List::isempty() { if (head == NULL) return true; else return false; }
//insert after prev, data d void List::insert(Node *prev, int d) { Node *temp = head; Node *ne = new Node; ne->data = d; if (temp == NULL) { cout << "previous is null, exiting" << endl; exit(1); } else while (temp->data != prev->data) {
temp = temp->next; } temp = temp->next; ne->next = temp; prev->next = ne;
}
//Search for a node and return the position where it was found //or -1 if it wasn't found int List::search(Node *n) { Node *temp = head; int i = 0; if (n != NULL) { if (isempty()) { cout << "Empty list, Not found" << endl; return -1; } else { while (temp != NULL) { if (temp->data == n->data) return i; temp = temp->next; i = i + 1; }
} if (temp == NULL) return -1; else return i; } else cout << "Searching for non-existent node, exiting now....." << endl; return -1; }
//Return the node if it exists. Node* List::getNode(int d) { Node *temp = head; if (head == NULL) { cout << "Empty list, exiting"; return NULL; } else { while (temp != NULL&&temp->data != d) temp = temp->next; } if (temp == NULL) { cout << "Trying to get a node that does not exist. Exiting" << endl; return NULL; } else return temp; }

//find the max of a list int List::max() { Node *temp = head; if (head == NULL) { cout << "Empty list, exiting" << endl; exit(1); }
else { int m = temp->data; temp = temp->next; while (temp != NULL) { if (m < temp->data) m = temp->data; temp = temp->next; }
return m; } }

PROBLEMS: Part 1: Design a- (5 pts) Create an Address class that contains the name and number of street, city, and zip code. Write all constructors, getters, setters and a Print functions for it b- (1o pts) Your class should provide input (overload the operator >>), output (operator prototype is similar to that of (istream& os, Address& a) (inside the function ask the user to enter the info, using cin or getline). The operator > should ask the user to enter a complete address and return a reference to it. The rock group "Marron 5" is giving a concert in your town and you have been hired by the night club where they are playing. The club seats 100 people, and tickets will be sold in advance. Ticket requests are to be filled in the order in which they are received, with a maximum of four tickets per person a- (5 pts) Write a ticketOrder class that stores a person name, address (use your class address that you created in part a), and number of tickets in a ticket order. Write all constructors, getters, setters and a Print functions for it. b- (10 pts) Your class should provide input function (do not overload the operator >> here), output (overload the operator you created in class Address to enter an address

Explanation / Answer

part - 2

#include<iostream>
#include<conio>
class Linkedlist
{
    public:
    char name[20];
    char add[20];
    int no;
    class Linkedlist *next;
};

main()

{
    Linkedlist *point,*first;
    first=new(class Linkedlist);
    point=first;
    while(1)
    {
        clrscr();
        cout<<"Please enter the name:";
        cin>>point->name;
        cout<<"Please enter the address:";
        cin>>point->add;
        cout<<"Please enter the no:";
        cin>>point->no;
        char ans;
        while(1)
        {
            cout<<" Do you want to continue(y/n):";
            cin>>ans;
            if(ans=='y' || ans=='Y')
            {
                break;
            }
            elseif(ans=='n' || ans=='N')
            {
                break;
            }
            else
            {
                cout<<"Invalid input";
            }
      }
      if(ans=='y' || ans=='Y')
      {
            point->next= new(class Linkedlist);
            point=point->next;
            continue;
      }
      else
      {
            point->next=NULL;
            break;
        }
}

point=first;
while(point!=NULL)
{
    cout<<"Name is   :"<<point->name<<endl;
cout<<"address is   :"<<point->add<<endl;
    cout<<"no is :"<<point->no<<endl;
    getch();
    point=point->next;
}
delete point;
delete first;
}

   return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote