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

Please Write C++ PROGRAM : That will write a program that initially prompts the user for...
Please Write C++ PROGRAM : That will write a program that initially prompts the user for a file name. If the file is not found, an error message is output, and the program terminates. Otherwise, the program prints each token in the file, and the number of times it appeared, in a well formatted manner. To accomplish all this, do the following: - Open the file - the user must be prompted and a file name input. DO NOT hardcode...
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 *...
How to do this in Python (using Lists): Create a python program that allows a user...
How to do this in Python (using Lists): Create a python program that allows a user to display, sort and update as needed a List of U.S States containing the State Capital and State Bird. You will need to embed the State data into your Python code. The user interface will allow the user to perform the following functions: 1. Display all U.S. States in Alphabetical order along with Capital and Bird 2. Search for a specific state and display...
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...
Create a Python program that: Allows the user to enter a phrase or sentence. The program...
Create a Python program that: Allows the user to enter a phrase or sentence. The program should then take the phrase or sentence entered Separate out the individual words entered Each individual word should then be added to a list After all of the words have been place in a list Sort the contents of the list Display the contents of the sorted list with each individual word displayed on a separate line Display a message to the user indicating...
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...
Please code C# 10. Write a program that allows a user to input names and corresponding...
Please code C# 10. Write a program that allows a user to input names and corresponding heights (assumed to be in inches). The user can enter an indefinite number of names and heights. After each entry, prompt the user whether they want to continue. If the user enters true, ask for the next name and height. If the user enters false, display the name of the tallest individual and their height. Sample run: “Name?” James “Height?” 50 “Continue?” True “Name?”...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT