Question

Write a program that uses a class or structure to store the following data about a...

Write a program that uses a class or structure to store the following data about a customer account.

Name

Address

City, State and Zip

Telephone Number

Account Balance

Date of Last Payment

The program should use an array or vector of 10 objects. It should let the users enter data, change the contents of any element and display all the data stored in the array or vector. The program should be modular and menu driven. Validation: When the data for a new account is entered, be sure the user enters data for all the fields. No negative account balance should be entered. Testing: Test your program for all the valid and invalid scnerios.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

`Hey,

Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <cstdlib>

using namespace std;

//structure customer
struct customer
{
//structure variables
string name,
address,
cityStateZip,
telephone_Number,
date_Last_Payment;

double AccountBalance;
};

//method to clear the screen

//menu driven option
void mainMenu()
{
cout<<"1) ENTER NEW RECORD"<<endl;
cout<<"2) CHANGE RECORD"<<endl;
cout<<"3) DISPLAY RECORD"<<endl;
cout<<"4) EXIT PROGRAM"<<endl;
}

//method to create new record
customer newRecord()
{
customer newRA;
cout<<"NEW RECORD"<<endl;
cout<<"PLEASE ENTER THE CUSTOMER'S NAME ";
getline(cin, newRA.name);
while(newRA.name.empty())
{
cout<< "PLEASE RE-ENTER THE CUSTOMER'S NAME ";
getline(cin, newRA.name);
}
cout<<"PLEASE ENTER THE CUSTOMER'S ADDRESS ";
getline(cin,newRA.address);
while (newRA.address.empty())
{
cout<<"PLEASE RE-ENTER THE CUSTOMER'S ADDRESS ";
getline(cin, newRA.address);
}
cout<<"PLEASE ENTER CITY, STATE, AND ZIP ";
getline(cin, newRA.cityStateZip);
while(newRA.cityStateZip.empty())
{
cout<<"PLEASE RE-ENTER THE CITY, STATE, AND ZIP ";
getline(cin, newRA.cityStateZip);
}
cout<<"PLEASE ENTER PHONE NUMBER EX. 9164578920 ";
getline(cin, newRA.telephone_Number);
while(newRA.telephone_Number.length() != 10)
{
cout<<"PLEASE RE-ENTER PHONE NUMBER ";
getline(cin, newRA.telephone_Number);
}
cout<<"PLEASE ENTER THE ACCOUNT BALANCE OF THE CUSTOMER: $";
cin>>newRA.AccountBalance;
cin.ignore();
while (newRA.AccountBalance < 0)
{
cout<<"ACCOUNT BALANCE MUST BE POSITIVE TO OPEN THE ACCOUNT"<<endl;
cout<<"PLEASE RE-ENTER THE ACCOUNT BALANCE: $";
cin>>newRA.AccountBalance;
cin.ignore();
}
cout<<"PLEASE ENTER THE DATE OF THE LAST PAYMENT EX 01/01/2005 ";
getline(cin, newRA.date_Last_Payment);

while (newRA.date_Last_Payment.length() != 10)
{
cout<<"PLEASE RE-ENTER THE DATE OF LAST PAYMENT EX 01/01/2005 ";
getline(cin, newRA.date_Last_Payment);
}

return newRA;
}
//method to change the old record
customer changeRecord(customer chgR)
{
char responseUser;
do {
cout<<"CHANGE RECORD"<<endl;
cout<<"a) NAME"<<endl;
cout<<"b) ADDRESS"<<endl;
cout<<"c) CITY, STATE, AND ZIP"<<endl;
cout<<"d) TELEPHONE NUMBER"<<endl;
cout<<"e) ACCOUNT BALANCE"<<endl;
cout<<"f) DATE OF LAST PAYMENT"<<endl;
cout<<"g) EXIT"<<endl;
cout<<"YOUR CHOICE: ";
cin>>responseUser;
cin.ignore();

if (responseUser=='a')
{
cout<<"PLEASE ENTER THE CUSTOMER'S NAME ";
getline(cin, chgR.name);
while(chgR.name.empty())
{
cout<< "PLEASE RE-ENTER THE CUSTOMER'S NAME ";
getline(cin, chgR.name);
}
}

if (responseUser=='b')
{
cout<<"PLEASE ENTER THE CUSTOMER'S ADDRESS ";
getline(cin,chgR.address);
while (chgR.address.empty())
{
cout<<"PLEASE RE-ENTER THE CUSTOMER'S ADDRESS ";
getline(cin, chgR.address);
}

}

if (responseUser=='c')
{
cout<<"PLEASE ENTER CITY, STATE, AND ZIP ";
getline(cin, chgR.cityStateZip);
while(chgR.cityStateZip.empty())
{
cout<<"PLEASE RE-ENTER THE CITY, STATE, AND zip ";
getline(cin, chgR.cityStateZip);
}
}

if (responseUser=='d')
{
cout<<"PLEASE ENTER PHONE NUMBER EX. 9164578920 ";
getline(cin, chgR.telephone_Number);
while(chgR.telephone_Number.length() != 10)
{
cout<<"Please re-enter phone number ";
getline(cin, chgR.telephone_Number);
}

}

if (responseUser=='e')
{
cout<<"PLEASE ENTER THE ACCOUNT BALANCE OF THE CUSTOMER: $";
cin>>chgR.AccountBalance;
cin.ignore();
while (chgR.AccountBalance < 0)
{
cout<<"ACCOUNT BALANCE MUST BE POSITIVE TO OPEN THE ACCOUNT"<<endl;
cout<<"PLEASE RE-ENTER THE ACCOUNT BALANCE: $";
cin>>chgR.AccountBalance;
cin.ignore();
}
}

if (responseUser=='f')
{
cout<<"PLEASE ENTER THE DATE OF THE LAST PAYMENT EX 01/01/2005 ";
getline(cin, chgR.date_Last_Payment);

while (chgR.date_Last_Payment.length() != 10)
{
cout<<"PLEASE RE-ENTER THE DATE OF LAST PAYMENT EX 01/01/2005 ";
getline(cin, chgR.date_Last_Payment);
}
}
} while (responseUser != 'g');

return chgR;
}

void displayRecord(customer customerData)
{
cout<<"NAME: "<<customerData.name<<endl;
cout<<"ADDRESS: "<<customerData.address<<endl;
cout<<"CITY,STATE,ZIP: "<<customerData.cityStateZip<<endl;
cout<<"PHONE NUMBER: "<<customerData.telephone_Number<<endl;
cout<<"ACCOUNT BALANCE: $"<<customerData.AccountBalance<<endl;
cout<<"DATE OF LAST PAYMENT: "<<customerData.date_Last_Payment<<endl<<endl;
  
}

//main method
int main()
{
//variables
customer customerData[10];
  
int indexValue;
char responseUser,userChoice;
  
size_t found;
//text file
vector <string> Record;

  
string Str;
int j=0;


int size=j;

do {
mainMenu();
cin>>responseUser;
cin.ignore();
if (responseUser=='1') {
customerData[size]=newRecord();
size++;
}
else if (responseUser=='2')
{
cout<<"WHICH RECORD WOULD YOU LIKE TO CHANGE? "<<endl;
cout<<"1) SEARCH BY INDEX"<<endl;
cout<<"2) SEARCH BY NAME"<<endl;
cout<<"WHICH METHOD WOULD YOU PREFER?"<<endl;
cin>>userChoice;
cin.ignore();

if (userChoice=='1') {
  
cout<<"ENTER INDEX # ";
cin>>indexValue;
while (indexValue < 0 || indexValue > size)
{
cout<<"PLEASE RE-ENTER INDEX NUMBER";
cin>>indexValue;
}
customerData[indexValue]=changeRecord(customerData[indexValue]);
}

if (userChoice=='2') {
cout<<"ENTER CUSTOMER NAME" <<endl;
cin>>Str;
int hit=0;
for (int i=0; i<size; i++) {
found=customerData[i].name.find(Str);
if (found!=string::npos) {
indexValue=i;
hit=1;
}   
}
if(hit==0) cout<<"NO MATCHES FOUND"<<endl;
else customerData[indexValue]=changeRecord(customerData[indexValue]);
}
}
else if (responseUser =='3') {
for (int i=0; i < size; i++) {
cout<<"ACCOUNT "<<i<<endl;
displayRecord(customerData[i]);
}
cout<<"PRESS ANY KEY TO CONTINUE"<<endl;
fflush(stdin);
getchar();
}
  
  
else responseUser='4';
} while (responseUser != '4');
return 0;
}

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
Write a program that uses a class or structure to store the following data about a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program that uses a structure to store the following data about a customer account: Name Address City, sta...

    Write a program that uses a structure to store the following data about a customer account: Name Address City, state, and ZIP Telephone number Account Balance Date of last payment The program should use an vector of at least 20 structures. It should let the user enter data into the vector, change the contents of any element, and display all the data stored in the array. The program should have a menu-driven user interface. Input Validation: When the data for...

  • 11.9: Speakers Bureau Write a program that keeps track of a speaker's bureau. The program should...

    11.9: Speakers Bureau Write a program that keeps track of a speaker's bureau. The program should use a structure to store the following data about a speaker: Name Telephone Number Speaking Topic Fee Required The program should use an array of at least 10 structures. It should let the user enter data into the array, change the contents of any element, and display all the data stored in the array. The program should have a menu-driven interface. Input Validation: When...

  • Write a program that keeps track of a speakers’ bureau. The program should use a structure...

    Write a program that keeps track of a speakers’ bureau. The program should use a structure to store the following data about a speaker: (this is in C++) Name Telephone Number Speaking Topic Fee Required The program should use a vector of structures. It should let the user enter data into the vector, change the contents of any element, and display all the data stored in the vector. The program should have a menu-driven user interface. Input Validation: When the...

  • Write a program (C++) that shows Game sales. The program should use a structure to store...

    Write a program (C++) that shows Game sales. The program should use a structure to store the following data about the Game sale: Game company Type of Game (Action, Adventure, Sports etc.) Year of Sale Sale Price The program should use an array of at least 3 structures (3 variables of the same structure). It should let the user enter data into the array, change the contents of any element and display the data stored in the array. The program...

  • Customer Accounts This program should be designed and written by a team of students. Here are...

    Customer Accounts This program should be designed and written by a team of students. Here are some suggestions: Write a program that uses a structure to store the following information about a customer account: • Name • Address • City, state, and ZIP • Telephone number • Account balance • Date of last payment The structure should be used to store customer account records in a file. The program should have a menu that lets the user perform the following...

  • I need help with this code. I'm using C++ and Myprogramming lab to execute it. 11.7:...

    I need help with this code. I'm using C++ and Myprogramming lab to execute it. 11.7: Customer Accounts Write a program that uses a structure to store the following data about a customer account:      Customer name      Customer address      City      State      ZIP code      Telephone      Account balance      Date of last payment The program should use an array of at least 20 structures. It should let the user enter data into the array, change the contents of any element, and display all the...

  • Inventory Program (C++) Write a program that uses a structure to store the following inventory data...

    Inventory Program (C++) Write a program that uses a structure to store the following inventory data in a file: - Item Description -Quantity on Hand -Wholesale cost -Retail cost -Date Added to Inventory The program should have a menu that allows the user to perform the following tasks: -Add new records to file -Display any record in the file -Change any record in the file Input Validation: The program should not accept quantities, or wholesale or retail costs, less than...

  • please write in C++ Write a program that uses a structure to store the following inventory...

    please write in C++ Write a program that uses a structure to store the following inventory data in a file: The data can be either read from a text file or the keyboard Item name (string) Quantity on hand(int) Wholesale cost(double) Retail Cost(double) The program should have a menu that allows the user to perform the following tasks: Add new records to the file Display any record in the file User will provide the name of the item or the...

  • JAVA PLEASE Create a class called Account with the following instance data Integer id Double balance...

    JAVA PLEASE Create a class called Account with the following instance data Integer id Double balance Provides the following methods Default constructor (defaults balance to 100) Constructor with parameters for the ID and the starting balance Accessor and mutator methods for id and balance Method to perform a withdrawal Method to perform a deposit Create a class called Bank which has an array of Account objects. This class will manage the accounts. It must provide methods Do withdrawal Do deposits...

  • Create an Inventory class with data members for stock number, quantity, and price, and overloaded data...

    Create an Inventory class with data members for stock number, quantity, and price, and overloaded data entry and output operators. The data entry operator function should throw: - An error message, if the stock number is negative or higher than 999 - The quantity, if it is less than 0 - The price, if it is over $100.00 Then perform the following tasks: a. Write a main() function that instantiates an array of five Inventory objects, and accepts data for...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT