Question

In: Computer Science

PLEASE DO IN C++ Create an object-oriented program that initially allows the user to save customer...

PLEASE DO IN C++

Create an object-oriented program that initially allows the user to save customer information in the list and to search for a customer by specifying the customer’s ID.

Sample Run

Customer Information Management System

---------------------------------------------------------------

CUSTOMER DATA ENTRY:

Full Name (First, Last): Jenny Ha
Company: Convergent Laser Technologies
Street: 1000 International Ave
City: Oakland
State: CA
Zip Code: 94506
ID: 100

Continue Your Data Entry? (y/n): y

Full Name (First, Last): Bill Martinez
Company: Cisco Systems
Street: 2000 Jackson St
City: San Jose
State: CA
Zip Code: 95112
ID: 100
This ID exists! Try again.
ID: 200

Continue Your Data Entry? (y/n): n

---------------------------------------------------------------

CUSTOMER DATA SEARCH:

Enter Customer ID: 100

Jenny Ha
Convergent Laser Technologies
1000 International Ave
Oakland, CA 94506

Continue Your Data Search? (y/n): y

Enter Customer ID: 200

Bill Martinez
Cisco Systems
2000 Jackson St
San Jose, CA 95112

Continue Your Data Search? (y/n): y

Enter Customer ID: 99

No customer with that ID.

Continue Your Data Search? (y/n): n

---------------------------------------------------------------

Thank you for using my app!

Specifications

  • Draw a UML class diagram (a hand drawn image is also accepted) for your project.
  • Create a Customer class to store the customer data.
  • This class should include private data members: full name, company, street, city, state, zip code, and id.
  • This class should include public member functions: a constructor, getters, and setters. In addition, it should include a public member function that returns the full address (street, city, zip code, and state).
  • When the program starts, it should ask the user to enter the customer data and save it in an array of Customer objects. For this project, you can initially define the array with twenty elements and make sure each customer has a unique id.
  • Note that the size of the array is fixed, so your program should check the maximum number of customers in the array to prevent the out of bound access error.
  • To find the customer with the specified ID, you can loop through each Customer object in the array of Customer objects and check whether the specified ID matches or not.
  • If the specified ID isn’t found, display an appropriate message.

Solutions

Expert Solution

Here is your solution if you have any doubt, then you can write in the comment section.

Please give feedback.

Solution:

#include <iostream>
using namespace std;

class Customer
{
    //private variables
    private:
    string fullName;
    string company;
    string street;
    string city;
    string state;
    int zipCode;
    int id;
    
    public:
    //dummy constructor
    Customer()
    {
        
    }
    //constructor
    Customer(string fullName,string company,string street,string city,string state,int zipCode,int id)
    {
        this->fullName=fullName;
        this->company=company;
        this->street=street;
        this->city=city;
        this->state=state;
        this->zipCode=zipCode;
        this->id=id;
    }
    
    //getter methods
    string getFullName()
    {
        return this->fullName;
    }
    
    string getCompany()
    {
        return this->company;
    }
    
    string getStreet()
    {
        return this->street;
    }
    
    string getCity()
    {
        return this->city;
    }
    
    string getState()
    {
        return this->state;
    }
    
    int getZipCode()
    {
        return this->zipCode;
    }
    
    int getId()
    {
        return this->id;
    }
    
    //setter methods
    void setFullName(string fullName)
    {
        this->fullName=fullName;
    }
    
    void setCompany(string company)
    {
        this->company=company;
    }
    
    void setStreet(string street)
    {
        this->street=street;
    }
    
    void setCity(string city)
    {
        this->city=city;
    }
    
    void setState(string state)
    {
        this->state=state;
    }
    
    void setZipCode(int zipCode)
    {
        this->zipCode=zipCode;
    }
    
    
    //method to get fullAddress
    string getFullAddress()
    {
        string fullAddress=this->street+"\n";
        fullAddress+=(this->city+",");
        fullAddress+=(this->state+" ");
        fullAddress+=(to_string(this->zipCode));
        
        return fullAddress;
    }
};


int main()
{
    //creating array of object of class Customer
    Customer* c = new Customer[20];
    //variables
    int size=0;
    string fullName;
    string company;
    string street;
    string city;
    string state;
    int zipCode;
    int id;
    cout<<"Customer Information Management System\n";
    cout<<"---------------------------------------------------------------\n";
    cout<<"CUSTOMER DATA ENTRY:\n";
    char choice='y';
    //loop until choice is 'y'
    while(choice=='y')
    {
        if(size<20)
        {
            //read data 
            int flag=0;
            cout<<"Full Name (First, Last): ";
            getline(cin, fullName);
            cout<<"Company: ";
            getline(cin, company);
            cout<<"Street: ";
            getline(cin, street);
            cout<<"City: ";
            getline(cin, city);
            cout<<"State: ";
            getline(cin, state);
            cout<<"Zip Code: ";
            cin>>zipCode;
            cout<<"ID: ";
            cin>>id;
            //check if id is valid
            for(int i=0;i<size;i++)
            {
                if(c[i].getId()==id)
                {
                    flag=1;
                    break;
                }
            }
            //if not valid means already present
            if(flag==1)
            {
                while(1)
                {
                    flag=0;
                    cout<<"This ID exists! Try again.\n";
                    cout<<"ID: ";
                    cin>>id;
                    //check again
                    for(int i=0;i<size;i++)
                    {
                        if(c[i].getId()==id)
                        {
                            flag=1;
                            break;
                            
                        }
                    }
                    if(flag==0)
                    {
                        break;
                    }
                    
                }
                //if valid then insert
                c[size]=Customer(fullName,company,street,city,state,zipCode,id);
                size++;
            }
            else
            {
                //if valid then insert
                c[size]=Customer(fullName,company,street,city,state,zipCode,id);
                size++;
            }
            
        }
        //if array is full
        else
        {
            cout<<"Array is Full!\n";
        }
       
       //input choice
       cout<<"Continue Your Data Entry? (y/n): ";
       cin>>choice;
       //ignore for ignoring newline character
       cin.ignore();
       
    }
    
    cout<<"---------------------------------------------------------------\n";
    cout<<"CUSTOMER DATA SEARCH:\n";
    choice = 'y';
    //loop until choice is 'y'
    while(choice=='y')
    {
       int flag=0;
       cout<<"Enter Customer ID: ";
       cin>>id;
       //loop for searching
       for(int i=0;i<size;i++)
       {
           if(c[i].getId()==id)
           {
               cout<<c[i].getFullName()<<"\n";
               cout<<c[i].getCompany()<<"\n";
               cout<<c[i].getFullAddress()<<"\n";
               flag=1;
               break;
           }
       }
       //if not found
       if(flag!=1)
       {
           cout<<"No customer with that ID.\n";
       }
       
       
       cout<<"Continue Your Data Search? (y/n): ";
       cin>>choice;
    }
    cout<<"---------------------------------------------------------------\n";
    cout<<"Thank you for using my app!\n";
    return 0;
}

Output:

UML:

Thank You!

input Customer Information Management System CUSTOMER DATA ENTRY: Full Name (First, Last): Jenny Ha Company: Convergent Laser Technologies Street: 1000 International Ave City: Oakland State: CA Zip Code: 94506 ID: 100 Continue Your Data Entry? (y/n): Y Full Name (First, Last) : Bill Martinez Company: Cisco Systems Street: 2000 Jackson St City: San jose State: CA Zip Code: 95112 ID: 100 This ID exists! Try again. ID: 200 Continue Your Data Entry? (y/n): n CUSTOMER DATA SEARCH: Enter Customer ID: 100 Jenny Ha Convergent Laser Technologies 1000 International Ave Oakland, CA 94506 Continue Your Data Search? (y/n): Y

input State: CA Zip Code: 95112 ID: 100 This ID exists! Try again. ID: 200 Continue Your Data Entry? (y/n): n CUSTOMER DATA SEARCH: Enter Customer ID: 100 Jenny Ha Convergent Laser Technologies 1000 International Ave Oakland, CA 94506 Continue Your Data Search? (y/n): Y Enter Customer ID: 200 Bill Martinez Cisco Systems 2000 Jackson St San jose, CA 95112 Continue Your Data Search? (y/n): Y Enter Customer ID: 99 No customer with that ID. Continue Your Data Search? (y/n): n Thank you for using my app! - - Program finished with exit code 0 Press ENTER to exit console.


Related Solutions

Fat Percentage Calculator Create a C++ program that allows the user to enter the number of...
Fat Percentage Calculator Create a C++ program that allows the user to enter the number of calories and fat grams in a food. The application should display the percentage of the calories that come from fat. If the calories from fat are less than 30% of the total calories of the food, it should also display a message indicating the food is low in fat. One gram of fat has 9 calories, so: Calories from fat = fat grams *...
Create a basic program (C programming language) that accomplishes the following requirements: Allows the user to...
Create a basic program (C programming language) that accomplishes the following requirements: Allows the user to input 2 numbers, a starting number x and ending number y Implements a while loop that counts from x (start) to y(end). Inside the loop, print to the screen the current number Print rather the current number is even or odd If the number is even , multiply by the number by 3 and print the results to the screen. If the number is...
Kindly Do the program in C++ language Object Oriented Programming. Objectives  Implement a simple class...
Kindly Do the program in C++ language Object Oriented Programming. Objectives  Implement a simple class with public and private members and multiple constructors.  Gain a better understanding of the building and using of classes and objects.  Practice problem solving using OOP. Overview You will implement a date and day of week calculator for the SELECTED calendar year. The calculator repeatedly reads in three numbers from the standard input that are interpreted as month, day of month, days...
Write a GUI-based program that allows the user to open, edit, and save text files. The...
Write a GUI-based program that allows the user to open, edit, and save text files. The GUI should include a labeled entry field for the filename and multi-line text widget for the text of the file. The user should be able to scroll through the text by manipulating a vertical scrollbar. Include command buttons labeled Open, Save, and New that allow the user to open, save and create new files. The New command should then clear the text widget and...
DO IN C++ Secret Codes! Create a program that will accept a message from the user...
DO IN C++ Secret Codes! Create a program that will accept a message from the user and either encrypt ordecrypt it with the following algorithms: To encrypt: - get the character you wish to encrypt - find the index of that character in the alphabet array - add the shift offset to the index - add the increment to the index - "wrap around" the new index so the result is between 0 and 29 - find the character at...
C++ Vector Write a program that allows the user to enter the last names of the...
C++ Vector Write a program that allows the user to enter the last names of the candidates in a local election and the votes received by each candidate. The program should then output each candidate's name, votes received by that candidate, and the percentage of the total votes received by the candidate. Assume a user enters a candidate's name more than once and assume that two or more candidates receive the same number of votes. Your program should output the...
Using RAPTOR create a program that allows the user to input a list of first names...
Using RAPTOR create a program that allows the user to input a list of first names in on array and last names into a parallel array. Input should be terminated when the user enters a sentinel character. the output should be a list of email address where the address is of the following form: [email protected]
Android Studio. Java. Please create an application that -> An activity that allows user to enter...
Android Studio. Java. Please create an application that -> An activity that allows user to enter name, gender, date of birth, state of residence (selected from a pre-defined list: CA, AZ, NV, OR), email address and favorite website. This activity has a button "Show Data" that displays detail entered
Write a GUI that allows the user to do the following: Create a new Patient Database...
Write a GUI that allows the user to do the following: Create a new Patient Database if it doesn’t exist yet by the click of a button. Create a second button that populates the database with the appropriate Asset table if it does not exist yet, and fill the table with at least 10 patients. Connect to the Patient Database and display all current patients in a List by default. You will have to create a Patient Class. This class...
Please write the code JAVA Write a program that allows the user to enter the last...
Please write the code JAVA Write a program that allows the user to enter the last names of five candidates in a local election and the number of votes received by each candidate. The program should then output each candidate’s name, the number of votes received, and the percentage of the total votes received by the candidate. Your program should also output the winner of the election. A sample output is: Candidate      Votes Received                                % of Total Votes...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT