Fix the errors in the Customer class and the Program.    #include #include #include using namespace std; class Customer { // Constructor void Customer(string name, string address) : cust_name(name), cust_address(address) { acct_number = this.getNextAcctNumber(); } // Accessor to get the account number const int getAcctNumber() { return acct_number; } // Accessor to get the customer name string getCustName(} const { return cust_name; } // Accessor to get the customer address string getCustAddress() const { return cust_address; } // Set a customer name and address static void set(string name, string address); // Set a customer address void setAddress(string cust_address) { cust_address = cust_address; } // Get the next account number for the next customer. static const unsigned long getNextAcctNumber() { ++nextAcctNum; } // input operator friend Customer operator>> (istream& ins, Customer cust); // output operator friend void operator<< (const ostream& outs, const Customer &cust) const; private string cust_name; // customer name unsigned long acct_number; // account number string cust_address; // customer address static const unsigned long nextAcctNum; }; const int MAX_CUSTOMERS=20; // Change this to a smaller number to test. // Declare the class variable nextAcctNum unsigned long Customer::nextAcctNum=10000; // set the customer name and address // @param name: the customer name // @param address: the account address void Customer::set(string name, string address) : cust_name(name), cust_address(address) { } // input operator reads customer as a name and address on two separate lines. // name // address1 friend Customer Customer::operator>>(istream& ins, Customer cust) { getline(cin, cust.cust_name); getline(cin, cust.cust_address); return *this; } // output operator friend void Customer::operator<<(const ostream& out, const Customer& cust) const { out << acct_number << ": " << cust_name << "\n" << cust_address << endl; } int main() { Customer custList[MAX_CUSTOMERS]; ifstream infile; string filename; cout << "Enter the name of the file for input: "; cin >> filename; infile.open(filename); if (infile.fail()) { cout << "Error: failed to open file: " << filename; exit(1); } // Read in customer list. int size = 0; while (infile >> custList[size]) { if (++size == MAX_CUSTOMERS) break; } // Get customer address changes for (int i = 0; i < MAX_CUSTOMERS; i++) { int answer; cout << "Address change for " << custList.acct_number[i] << "? (y or n) : "; cin >> answer; if (answer == 'y') { cin.ignore(); // newline getline(cin, input); custList.setAddress[i] = input; } } // Write out customer list. for (int i = 0; I < MAX_CUSTOMERS; i++) { cout << custList[i]; } return 0; }

Principles of Information Systems (MindTap Course List)
12th Edition
ISBN:9781285867168
Author:Ralph Stair, George Reynolds
Publisher:Ralph Stair, George Reynolds
Chapter4: Software: Systems And Application Software
Section: Chapter Questions
Problem 1DQ2
icon
Related questions
Question

Fix the errors in the Customer class and the Program. 

 

#include <iostream>
#include <fstream>
#include <string>
using namespace std;

class Customer {

// Constructor
void Customer(string name, string address) : cust_name(name), cust_address(address)
{
acct_number = this.getNextAcctNumber();
}

// Accessor to get the account number
const int getAcctNumber() { return acct_number; }

// Accessor to get the customer name
string getCustName(} const { return cust_name; }

// Accessor to get the customer address
string getCustAddress() const { return cust_address; }

// Set a customer name and address
static void set(string name, string address);

// Set a customer address
void setAddress(string cust_address) { cust_address = cust_address; }

// Get the next account number for the next customer.
static const unsigned long getNextAcctNumber() { ++nextAcctNum; }

// input operator
friend Customer operator>> (istream& ins, Customer cust);

// output operator
friend void operator<< (const ostream& outs, const Customer &cust) const;

private
string cust_name; // customer name

unsigned long acct_number; // account number

string cust_address; // customer address

static const unsigned long nextAcctNum;
};

const int MAX_CUSTOMERS=20; // Change this to a smaller number to test.

// Declare the class variable nextAcctNum
unsigned long Customer::nextAcctNum=10000;

// set the customer name and address
// @param name: the customer name
// @param address: the account address
void Customer::set(string name, string address) : cust_name(name), cust_address(address)
{
}

// input operator reads customer as a name and address on two separate lines.
// name
// address1
friend Customer Customer::operator>>(istream& ins, Customer cust)
{
getline(cin, cust.cust_name);
getline(cin, cust.cust_address);
return *this;
}

// output operator
friend void Customer::operator<<(const ostream& out, const Customer& cust) const
{
out << acct_number << ": " << cust_name << "\n" << cust_address << endl;
}

int main()
{
Customer custList[MAX_CUSTOMERS];
ifstream infile;
string filename;

cout << "Enter the name of the file for input: ";
cin >> filename;

infile.open(filename);
if (infile.fail()) {
cout << "Error: failed to open file: " << filename;
exit(1);
}

// Read in customer list.
int size = 0;
while (infile >> custList[size]) {
if (++size == MAX_CUSTOMERS)
break;
}

// Get customer address changes
for (int i = 0; i < MAX_CUSTOMERS; i++)
{
int answer;
cout << "Address change for " << custList.acct_number[i] << "? (y or n) : ";
cin >> answer;
if (answer == 'y') {
cin.ignore(); // newline
getline(cin, input);
custList.setAddress[i] = input;
}
}

// Write out customer list.
for (int i = 0; I < MAX_CUSTOMERS; i++)
{
cout << custList[i];
}

return 0;
}

 

THE PICTURE IS OF THE DATA FILE AND OUTPUT

THE CORRECT OUTPUT OF THE TEST CASE
1 Enter the name of the file for input: Address change for
10001? (y or n) : Address change for
10002? (y or n) : Address change for 10003? (y or n) : Address cha
2 344 Park Ave, NY, NY 10022
3 10002: Kemp Technologies
3601 Broadway, NY, NY 10021
10003: Verizon
6 Hudson Street, NY, NY 10001
7 10004: Merrill Lynch
8 7 World Financial Center, NY, NY 10001
9 10005: Philips Laboratories
10 2 Canal Park, Cambridge, MA 02141
6.
11
Transcribed Image Text:THE CORRECT OUTPUT OF THE TEST CASE 1 Enter the name of the file for input: Address change for 10001? (y or n) : Address change for 10002? (y or n) : Address change for 10003? (y or n) : Address cha 2 344 Park Ave, NY, NY 10022 3 10002: Kemp Technologies 3601 Broadway, NY, NY 10021 10003: Verizon 6 Hudson Street, NY, NY 10001 7 10004: Merrill Lynch 8 7 World Financial Center, NY, NY 10001 9 10005: Philips Laboratories 10 2 Canal Park, Cambridge, MA 02141 6. 11
ThinkAbout Tech
344 Park Ave, NY, NY 10022
Kemp Technologies
3601 Broadway, NY, NY 10021
Verizon
6 Hudson Street, NY, NY 10001
Merrill Lynch
7 World Financial Center, NY, NY 10001
Philips Laboratories
345 Scarborough Rd, Briarcliff Manor, NY 10510
Transcribed Image Text:ThinkAbout Tech 344 Park Ave, NY, NY 10022 Kemp Technologies 3601 Broadway, NY, NY 10021 Verizon 6 Hudson Street, NY, NY 10001 Merrill Lynch 7 World Financial Center, NY, NY 10001 Philips Laboratories 345 Scarborough Rd, Briarcliff Manor, NY 10510
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
List
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Principles of Information Systems (MindTap Course…
Principles of Information Systems (MindTap Course…
Computer Science
ISBN:
9781285867168
Author:
Ralph Stair, George Reynolds
Publisher:
Cengage Learning
Fundamentals of Information Systems
Fundamentals of Information Systems
Computer Science
ISBN:
9781305082168
Author:
Ralph Stair, George Reynolds
Publisher:
Cengage Learning
MIS
MIS
Computer Science
ISBN:
9781337681919
Author:
BIDGOLI
Publisher:
Cengage