#include <iostream> #include <string> using namespace std; //Product class class Product { public: string name; float price; Product *next; }; //Customer class class Customer {
public: string firstname; string lastname; string type; Customer *next; Product item; Customer(); }; Customer::Customer() { firstname=""; lastname=""; type=""; item.name=""; item.price=0.0; }
int main() { Customer* addNewCust(Customer *); string delCust(Customer *,string); string addProduct(Customer *,string,string,float); string delProduct(Customer *,string); void printCustDetails(Customer *); string delAllProduct(Customer *); Customer* delAllCust(Customer *); Customer *db = NULL; Customer *head=NULL; Customer *curr=NULL; db = new Customer;
if(!head) { head = new Customer; curr = head; } else { curr = head; while(curr -> next) curr = curr -> next; } db->next = head; head->next = NULL; int option; char ch;
do { cout<<"n Please select any item from the following menu:"<<endl; cout<<"1: Add a new customer in the list."<<endl; cout<<"2: Delete a customer from the list."<<endl; cout<<"3: Add a product in the list of currently bought products of a customer."<<endl; cout<<"4: Delete a product from the list of products of a customer."<<endl; cout<<"5: Print all the customers along with their list of products."<<endl; cout<<"6: Delete all the products of a particular customer."<<endl; cout<<"7: Delete all the customers from the list."<<endl; cout<<"n Enter Menu Option [1-7] : "; cin>>option; string fname; string pname;
float price; switch(option) { case 1: curr = addNewCust(curr); break; case 2: cout<<"Enter Customer First name: "; cin>>fname; cout<<delCust(head,fname); break; case 3: cout<<"Enter Customer First name: "; cin>>fname; cout<<"Enter Product Name: "; cin>>pname; cout<<"Enter Product Price: ";
cin>>price; cout<<addProduct(head,fname,pname,price); break; case 4: cout<<delProduct(head,fname); break; case 5: printCustDetails(head); break; case 6: delAllProduct(head); break; case 7: head = delAllCust(head); break; default: cout<<"Enter Option from the list [1-7]"; break;
} cout<<"n Do you wish to continue: (y/n)"; cin>>ch; }while(ch!='n'); return 0; } Customer* addNewCust(Customer *cur) { Customer *c; c = new Customer(); cur->next = c; string f,l; cout<<"Adding New Customer"<<endl;
cout<<"Enter First Name:"; cin>>f; cout<<"Enter Last Name:"; cin>>l; c->firstname = f; c->lastname = l; c->next = NULL; c->item.name = " "; return c; } string delCust(Customer *hd,string fname) { cout<<"Deleting Customer"<<endl; while(hd) { if(hd->firstname.compare(fname)) {
//free(hd); cout<<hd->firstname; hd=NULL; return "nCustomer deleted!!"; } else hd = hd->next; } return "nNo Customer Found"; } string addProduct(Customer *hd,string fname,string pname, float price) { cout<<"Adding New Product"<<endl; while(hd) { if(hd->firstname.compare(fname))
{ hd->item.name = pname; hd->item.price = price; return "nProduct added!!"; } else hd = hd->next; } return "nCustomer not found"; } string delProduct(Customer *hd, string fname) { cout<<"Delete Product"<<endl; while(hd) { if(hd->firstname.compare(fname))
{ hd->item.name = " "; hd->item.price = 0.0; return "nProduct deleted!!"; } else hd = hd->next; } return "nCustomer not found"; } void printCustDetails(Customer *hd) { cout<<"Printing Customer and Product"<<endl; if(hd->next==NULL) { cout<<"No Data to print";
return; } string f,l; string type="normal"; string pname; float price; cout<<"n Customer Details "<<f<<" "<<l; while(hd) { f = hd->firstname; l = hd->lastname; cout<<f<<" "<<l; while(hd->item.price!=0.0) { if(hd->item.price > 1000) type = "excellent";
else if((hd->item.price < 1000) && (hd->item.price >100)) type = "good"; else type = "normal"; cout<<"Type :"<<type; pname = hd->item.name; price = hd->item.price; cout<<"n Products "<<"Name "<<pname<<"Price"<<price; hd->item.next = hd->item.next; break; } hd = hd->next; } } string delAllProduct(Customer *hd) { cout<<"Delete All Products"<<endl;
if(hd==NULL) cout<<"No product to delete"; while(hd) { string f = hd->firstname; string l = hd->lastname; cout<<"n Customer Details: "<<f<<" "<<l; while(hd->item.name!=" ") { hd->item.name =" "; return "nItems deleted"; break; } hd = hd->next; }
return "n No items to delete for customer"; } Customer* delAllCust(Customer *hd) { cout<<"Delete All Customer"<<endl; hd=NULL; cout<<"All Customer deleted"; return hd; } DUE TONIGHT.. Please respond in 150-300 words to: Do you think that the technology tools provided by University of Phoenix (such as the career plan, tutorials, smartphone apps, and PhoenixConnect) will be useful to your education? Why or why not? Which tools in particular do you feel would be the most useful?
#include iostream#include stringusing namespace std;.docx

#include iostream#include stringusing namespace std;.docx

  • 1.
    #include <iostream> #include <string> usingnamespace std; //Product class class Product { public: string name; float price; Product *next; }; //Customer class class Customer {
  • 2.
    public: string firstname; string lastname; stringtype; Customer *next; Product item; Customer(); }; Customer::Customer() { firstname=""; lastname=""; type=""; item.name=""; item.price=0.0; }
  • 3.
    int main() { Customer* addNewCust(Customer*); string delCust(Customer *,string); string addProduct(Customer *,string,string,float); string delProduct(Customer *,string); void printCustDetails(Customer *); string delAllProduct(Customer *); Customer* delAllCust(Customer *); Customer *db = NULL; Customer *head=NULL; Customer *curr=NULL; db = new Customer;
  • 4.
    if(!head) { head = newCustomer; curr = head; } else { curr = head; while(curr -> next) curr = curr -> next; } db->next = head; head->next = NULL; int option; char ch;
  • 5.
    do { cout<<"n Please selectany item from the following menu:"<<endl; cout<<"1: Add a new customer in the list."<<endl; cout<<"2: Delete a customer from the list."<<endl; cout<<"3: Add a product in the list of currently bought products of a customer."<<endl; cout<<"4: Delete a product from the list of products of a customer."<<endl; cout<<"5: Print all the customers along with their list of products."<<endl; cout<<"6: Delete all the products of a particular customer."<<endl; cout<<"7: Delete all the customers from the list."<<endl; cout<<"n Enter Menu Option [1-7] : "; cin>>option; string fname; string pname;
  • 6.
    float price; switch(option) { case 1: curr= addNewCust(curr); break; case 2: cout<<"Enter Customer First name: "; cin>>fname; cout<<delCust(head,fname); break; case 3: cout<<"Enter Customer First name: "; cin>>fname; cout<<"Enter Product Name: "; cin>>pname; cout<<"Enter Product Price: ";
  • 7.
    cin>>price; cout<<addProduct(head,fname,pname,price); break; case 4: cout<<delProduct(head,fname); break; case 5: printCustDetails(head); break; case6: delAllProduct(head); break; case 7: head = delAllCust(head); break; default: cout<<"Enter Option from the list [1-7]"; break;
  • 8.
    } cout<<"n Do youwish to continue: (y/n)"; cin>>ch; }while(ch!='n'); return 0; } Customer* addNewCust(Customer *cur) { Customer *c; c = new Customer(); cur->next = c; string f,l; cout<<"Adding New Customer"<<endl;
  • 9.
    cout<<"Enter First Name:"; cin>>f; cout<<"EnterLast Name:"; cin>>l; c->firstname = f; c->lastname = l; c->next = NULL; c->item.name = " "; return c; } string delCust(Customer *hd,string fname) { cout<<"Deleting Customer"<<endl; while(hd) { if(hd->firstname.compare(fname)) {
  • 10.
    //free(hd); cout<<hd->firstname; hd=NULL; return "nCustomer deleted!!"; } else hd= hd->next; } return "nNo Customer Found"; } string addProduct(Customer *hd,string fname,string pname, float price) { cout<<"Adding New Product"<<endl; while(hd) { if(hd->firstname.compare(fname))
  • 11.
    { hd->item.name = pname; hd->item.price= price; return "nProduct added!!"; } else hd = hd->next; } return "nCustomer not found"; } string delProduct(Customer *hd, string fname) { cout<<"Delete Product"<<endl; while(hd) { if(hd->firstname.compare(fname))
  • 12.
    { hd->item.name = ""; hd->item.price = 0.0; return "nProduct deleted!!"; } else hd = hd->next; } return "nCustomer not found"; } void printCustDetails(Customer *hd) { cout<<"Printing Customer and Product"<<endl; if(hd->next==NULL) { cout<<"No Data to print";
  • 13.
    return; } string f,l; string type="normal"; stringpname; float price; cout<<"n Customer Details "<<f<<" "<<l; while(hd) { f = hd->firstname; l = hd->lastname; cout<<f<<" "<<l; while(hd->item.price!=0.0) { if(hd->item.price > 1000) type = "excellent";
  • 14.
    else if((hd->item.price <1000) && (hd->item.price >100)) type = "good"; else type = "normal"; cout<<"Type :"<<type; pname = hd->item.name; price = hd->item.price; cout<<"n Products "<<"Name "<<pname<<"Price"<<price; hd->item.next = hd->item.next; break; } hd = hd->next; } } string delAllProduct(Customer *hd) { cout<<"Delete All Products"<<endl;
  • 15.
    if(hd==NULL) cout<<"No product todelete"; while(hd) { string f = hd->firstname; string l = hd->lastname; cout<<"n Customer Details: "<<f<<" "<<l; while(hd->item.name!=" ") { hd->item.name =" "; return "nItems deleted"; break; } hd = hd->next; }
  • 16.
    return "n Noitems to delete for customer"; } Customer* delAllCust(Customer *hd) { cout<<"Delete All Customer"<<endl; hd=NULL; cout<<"All Customer deleted"; return hd; } DUE TONIGHT.. Please respond in 150-300 words to: Do you think that the technology tools provided by University of Phoenix (such as the career plan, tutorials, smartphone apps, and PhoenixConnect) will be useful to your education? Why or why not? Which tools in particular do you feel would be the most useful?