Question

In: Computer Science

C++ 1.0: Customer Module Create a customer account module to hold the residents details. Use a...

C++

1.0: Customer Module

Create a customer account module to hold the residents details. Use a structure to store the following data about the customer account:

Field

Description

Account No

Start with character C and followed by 5 digits (e.g. C10212)

Name

Resident name

Address

Current housing address

Plot Number

Special identifier of the house (3 digits value)

Contact No

Resident HP number (e.g. 0125354123)

Date of Last Payment

Date in (dd-mm-yyyy) format. (e.g 15-12-2019)

Monthly Payment Amount

Example $130.00

Account Balance

Advance payment in the account

The structure should be used to store customer account records in a file. In this module, you should provide a menu (refer to figure 1.0) that lets the user perform the following operations:

  1. Enter a new customer record into the file
  2. Search for a particular customer’s record and display it.
  3. Search for a particular customer’s record and delete it.
  4. Search for a particular customer’s record and change it.
  5. Display all the customer records.
  6. Display the customer records with outstanding payments (For example if the monthly payment is $200. Two consecutive outstanding payments will record -400 in account balance column).

<>

  1. New Record
  2. Search Record
  3. Delete Record
  4. Edit Record
  5. List Records
  6. Outstanding records
  7. Exit

Enter Option:

Enter Option:

<>

  1. Customer Management
  2. Payment
  3. Exit

Enter Option:

Solutions

Expert Solution

#include <iostream>
#include <string>
#include <vector>

class Date{
public:
Date(){}
Date(int d, int m, int y){
    day = d;
    month = m;
    year = y;
}
int getDay() const{ return day; }
int getMonth() const{ return month; }
int getYear() const{ return year; }
void setDay(int d){ day = d; }
void setMonth(int m){ month = m; }
void setYear(int y){ year = y; }
friend std::ostream& operator<<(std::ostream&, const Date&);
friend std::istream& operator>>(std::istream&, Date&);
private:
int day, month, year;
};

std::ostream& operator<<(std::ostream& o, const Date& dt)
{
o<<dt.getDay()<<"-"<<dt.getMonth()<<"-"<<dt.getYear();
return o;
}

std::istream& operator>>(std::istream& i, Date& dt)
{
int d, m, y;
i>>d;
i>>m;
i>>y;
dt.setDay(d);
dt.setMonth(m);
dt.setYear(y);
return i;
}

struct Customer{
std::string accountNo;
std::string name;
std::string address;
int plotNo;
int contactNo;
Date lastPayment;
double monthlyPayment;
double accountBalance;
};

class CustomerModule{
public:
CustomerModule(){}
void addNewCustomer(){
    Customer c;
    std::cout<<"Enter AccountNo: ";
    std::cin>>c.accountNo;
    std::cout<<"Enter Name: ";
    std::cin>>c.name;
    std::cout<<"Enter Address: ";
    std::cin>>c.address;
    std::cout<<"Enter PlotNo: ";
    std::cin>>c.plotNo;
    std::cout<<"Enter ContactNo: ";
    std::cin>>c.contactNo;
    std::cout<<"Enter Date of last payment(dd-mm-yyyy): ";
    std::cin>>c.lastPayment;
    std::cout<<"Enter Monthly payment: ";
    std::cin>>c.monthlyPayment;
    std::cout<<"Enter Account balance: ";
    std::cin>>c.accountBalance;
    customers.push_back(c);
}

void searchAndDisplay(){
    std::string name;
    std::cout<<"Enter Customer name: ";
    std::cin>>name;
    std::vector<Customer>::iterator it = customers.begin();
    while(it != customers.end()){
      if((*it).name == name){
        displayCustomer(*it);
        return;
      }
      it++;
    }
    std::cout<<"Customer "<<name<<" cannot found!"<<std::endl;
}

void searchAndDelete(){
    std::string name;
    std::cout<<"Enter Customer name: ";
    std::cin>>name;
    std::vector<Customer>::iterator it = customers.begin();
    while(it != customers.end()){
      if((*it).name == name){
        customers.erase(it);
        return;
      }
      it++;
    }
    std::cout<<"Customer "<<name<<" cannot found!"<<std::endl;
}

void searchAndEdit(){
    std::string name;
    std::cout<<"Enter Customer name: ";
    std::cin>>name;
    std::vector<Customer>::iterator it = customers.begin();
    while(it != customers.end()){
      if((*it).name == name){
        std::cout<<"Edit "<<name<<"'s record: "<<std::endl;
        std::cout<<"Enter AccountNo: ";
        std::cin>>(*it).accountNo;
        std::cout<<"Enter Name: ";
        std::cin>>(*it).name;
        std::cout<<"Enter Address: ";
        std::cin>>(*it).address;
        std::cout<<"Enter PlotNo: ";
        std::cin>>(*it).plotNo;
        std::cout<<"Enter ContactNo: ";
        std::cin>>(*it).contactNo;
        std::cout<<"Enter Date of last payment(dd-mm-yyyy): ";
        std::cin>>(*it).lastPayment;
        std::cout<<"Enter Monthly payment: ";
        std::cin>>(*it).monthlyPayment;
        std::cout<<"Enter Account balance: ";
        std::cin>>(*it).accountBalance;
        return;
      }
      it++;
    }
    std::cout<<"Customer "<<name<<" cannot found!"<<std::endl;
}

void display(){
    std::vector<Customer>::iterator it = customers.begin();
    std::cout<<"Customers: "<<std::endl;
    while(it != customers.end()){
      displayCustomer(*it);
      std::cout<<"-----------------------------"<<std::endl;
      it++;
    }
}

void outstandingRecords(){
    std::vector<Customer>::iterator it = customers.begin();
    std::cout<<"Outstanding records: "<<std::endl;
    while(it != customers.end()){
      if((*it).monthlyPayment >= 200){
        std::cout<<" AccountNo: "<<(*it).accountNo<<" Name: "<<(*it).name
        <<" Balance will be: "<<(*it).monthlyPayment * 2<<std::endl;
      }
      it++;
    }
}

private:
void displayCustomer(const Customer& c){
    std::cout<<" AccountNo: "<<c.accountNo<<std::endl;
    std::cout<<" Name: "<<c.name<<std::endl;
    std::cout<<" Address: "<<c.address<<std::endl;
    std::cout<<" PlotNo: "<<c.plotNo<<std::endl;
    std::cout<<" ContactNo: "<<c.contactNo<<std::endl;
    std::cout<<" Date of Last payment: "<<c.lastPayment<<std::endl;
    std::cout<<" Monthly payment: "<<c.monthlyPayment<<std::endl;
    std::cout<<" Account Balance: "<<c.accountBalance<<std::endl;
}

private:
std::vector<Customer> customers;
};

int main()
{
int choice;
CustomerModule customer;
while(true){
    std::cout<<"*** Customer Module ***"<<std::endl;
    std::cout<<"1 New Record"<<std::endl;
    std::cout<<"2 Search Record"<<std::endl;
    std::cout<<"3 Delete Record"<<std::endl;
    std::cout<<"4 Edit Record"<<std::endl;
    std::cout<<"5 List Records"<<std::endl;
    std::cout<<"6 Outstanding records"<<std::endl;
    std::cout<<"7 Exit"<<std::endl;
    std::cout<<"Enter option: ";
    std::cin>>choice;
    switch(choice){
      case 1:
        customer.addNewCustomer();
        break;
      case 2:
        customer.searchAndDisplay();
        break;
      case 3:
        customer.searchAndDelete();
        break;
      case 4:
        customer.searchAndEdit();
        break;
      case 5:
        customer.display();
        break;
      case 6:
        customer.outstandingRecords();
        break;
      case 7:
        return 0;
      default:
        std::cout<<"Invalid choice!"<<std::endl;
        break;
    }
}
return 0;
}


Related Solutions

(In C++) Bank Account Program Create an Account Class Create a Menu Class Create a main()...
(In C++) Bank Account Program Create an Account Class Create a Menu Class Create a main() function to coordinate the execution of the program. We will need methods: Method for Depositing values into the account. What type of method will it be? Method for Withdrawing values from the account. What type of method will it be? Method to output the balance of the account. What type of method will it be? Method that will output all deposits made to the...
Write a program in c++ to do the following: 2. Create an array to hold up...
Write a program in c++ to do the following: 2. Create an array to hold up to 20 integers. 3. Create a data file or download attached text file (twenty_numbers.txt) that contains UP TO 20 integers. 4. Request the input and output file names from the user. Open the files being sure to check the file state. 5. Request from the user HOW MANY numbers to read from the data file, up to twenty. Request the number until the user...
c++ Create a class named EvolutionTree which will hold a list of species and their expected...
c++ Create a class named EvolutionTree which will hold a list of species and their expected age, and allow a user to search for a particular species or an age. EvolutionTree should have private data members: species (a string array of size 400 with all the species) speciesAges (an int array of size 400 for all the species' ages). EvolutionTree should have a default constructor which should initialize the species array to empty strings ("") and initialize the speciesAges array...
. Create a half adder circuit using ladder logic. Use an input module to collect the...
. Create a half adder circuit using ladder logic. Use an input module to collect the values from two switches A0 and B0 and an output module to deliver the output Sum and Carry signals to bulbs. Use a ladder diagram to create the logic. You should be able to alter the switches and check the operation of your logic by checking which bulbs come on. You can’t use the logic convertor for ladder logic diagrams. Show your circuit, and...
Use R programming to resolve this; can you please provide details on the code? A) Create...
Use R programming to resolve this; can you please provide details on the code? A) Create a dataframe – comparativeGenomeSize with the following vectors: > organism<-c("Human","Mouse","Fruit Fly", "Roundworm","Yeast") > genomeSizeBP<-c(3000000000,3000000000,135600000,97000000,12100000) > estGeneCount<-c(30000,30000,13061,19099,6034) B) Print the organism and estGeneCount for Human and fruitfly.(1) C) Add a column to this data frame calculating base pairs per gene. To do this, write a function “genedensity” that takes as arguments the genomesizeBP and estimatedGeneCount information, and calculates from this the estimated bp per gene....
Needed in C++ In this assignment, you are asked to create a class called Account, which...
Needed in C++ In this assignment, you are asked to create a class called Account, which models a bank account. The requirement of the account class is as follows (1) It contains two data members: accountNumber and balance, which maintains the current account name and balance, respectively. (1) It contains three functions: functions credit() and debit(), which adds or subtracts the given amount from the balance, respectively. The debit() function shall print ”amount withdrawn exceeds the current balance!” if the...
use linux or c program. please provide the answer in details. Write a program that will...
use linux or c program. please provide the answer in details. Write a program that will simulate non - preemptive process scheduling algorithm: First Come – First Serve Your program should input the information necessary for the calculation of average turnaround time including: Time required for a job execution; Arrival time; The output of the program should include: starting and terminating time for each job, turnaround time for each job, average turnaround time. Step 1: generate the input data (totally...
C++ Linkedlist Create a food menu so the customer can see what we are selling, if...
C++ Linkedlist Create a food menu so the customer can see what we are selling, if the users place order that not on the menu, prompt the users to enter again. Food code and food must be matched when users enter.
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:...
C# windows application form. Create a base class to store characteristics about a loan. Include customer...
C# windows application form. Create a base class to store characteristics about a loan. Include customer details in the Loan base class such as name, loan number, and amount of loan. Define subclasses of auto loan and home loan. Include unique characteristics in the derived classes. For example you might include details about the specific auto in the auto loan class and details about the home in the home loan class. Create a presentation class to test your design by...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT