Design a generic class or structure to store the following information about a c
ID: 666304 • Letter: D
Question
Design a generic class or 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 class or structure should be used to store customer account recors in a file. The program should have a menu that lets the user perform the following operations:
Enter new records into the file
Search for a particular customers record and display it.
Search for a particular customers record and delete it.
Search for a particular customers record and change it.
Display the contents of the entire file
I keep getting errors on my code but I can't figure out what I am doing wrong.
#include "stdafx.h"
#include <cstdlib>
#include <iostream>
using namespace std;
void Acc(string , int, int AcArray[]);
void Load(string, string, int AcArray[]);
void Display(int AcArray[]);
void menu();
double CBalance(int AcArray[]);
void question();
struct account
{
char name[30]; //customer name
char address[30]; // address
char city[16]; //city
char state[2]; // State two letters
char zip[5]; // zip 5 numbers
char tele[12]; // telephone number 12 characters
double account; // account total
char date[20]; // date
int total[30]; // total array length
};
int main(int argc, char *argv[])
{
int AcArray[30];
//menu;
system("PAUSE");
return EXIT_SUCCESS;
}
void menu();
{
int choice;
cout << "Welcome to you account management software, which action would you like to take?" << endl;
cout << "Press 1. Enter a new account." << endl;
cout << "Press 2. Display current account balances." << endl;
cout << "Press 3. Edit current accounts." << endl;
cout << "Press 4. Edit current balance of an account." << endl;
cin >> choice;
swtich(choice)
{
case 1:
cout << "You have chosen to enter a new account." << endl;
Acc;
break;
case 2:
CBalance;//call account balance function
break;
case 3:
cout << "Which account would you like to edit?"
//Display account numbers
//Call account number selected
break;
case 4:
cout << " Which account balance would you like to edit?"
//Display all current account numbers
//Call the array stored with account selected number
}
}
void question
{
char YN;
cout << "Would you like to return to the main menu y or n?";
cin >> YN;
switch(YN)
{
case y:
menu;
break;
case n:
return 0;
break;
}
}
double CBalance(int AcArray[])
{
cout <<"current balance is: " << account << endl;
}
void Acc(int total, int c, AcArray[])
{
cout << "How many account would you like to have?";
cin >> total;
Accout AcArray[total]
for(int c = 0; c < total; c++)
{
Load(total, c, AcArray);
}
for(int d = 0; d < total; d++)
{
Display(AcArray);
}
}
void Load(int total, int c, AcArray[])
{
cout << "Enter the full name of customer(First Last) ";
cin >> name;
cout << endl;
cout << "Enter the Address(i.e. 3470 NW 193 ST) of the customer ";
cin >> address;
cout << endl;
cout << "Enter the City of customer ";
cin >> city;
cout << endl;
cout << "Enter the State of customer ";
cin >> state;
cout << endl;
cout << "Enter the Zip Code of customer ";
cin >> zip;
cout << endl;
cout << "Enter the Telephone number(i.e 4597894561) of customer ";
cin >> tele;
cout << endl;
cout << "Enter the current account balance(i.e 789.55) of customer ";
cin >> account;
cout << endl;
cout << "Enter the last Day(i.e March 5, 2009) paid by customer ";
cin >> date;
cout << endl;
}
void Display
{
cout << " Customer " << c << " Name is " << AcArray[] << endl;
cout << " Customer " << c << " Address is " << AcArray[] << endl;
cout << " Customer " << c << " City is " << AcArray[] << endl;
cout << " Customer " << c << " State is " << AcArray[] << endl;
cout << " Customer " << c << " Zip Code is " << AcArray[] << endl;
cout << " Customer " << c << " Telephone number is " << AcArray[] << endl;
cout << " Customer " << c << " current account balance is $" << AcArray[] << endl;
cout << " Customer " << c << " last Day paid is " << AcArray[] << endl;
}
Explanation / Answer
//Corrected version of the program:
//#include "stdafx.h"
#include <iostream>
#include <string.h>
using namespace std;
int Acc(struct Account AcArray[]);
void Load(int, int, struct Account AcArray[]);
void Display(int,struct Account AcArray[]);
void menu(struct Account AcArray[]);
void CBalance(int total,struct Account AcArray[]);
void AccEdit(int total,struct Account AcArray[]);
void question(struct Account AcArray[]);
void modify(int,int,struct Account AcArray[]);
void del(int,int,struct Account AcArray[]);
struct Account
{
char name[30]; //customer name
char address[30]; // address
char city[16]; //city
char state[2]; // State two letters
char zip[5]; // zip 5 numbers
char tele[12]; // telephone number 12 characters
int account; // account number
double balance;
char date[20]; // date
};
int main(int argc, char *argv[])
{
struct Account AcArray[30];
menu(AcArray);
}
void menu(struct Account AcArray[])
{
int choice;
int total;
cout << "Welcome to you account management software, which action would you like to take?" << endl;
cout << "Press 1. Enter new account." << endl;
cout << "Press 2. Display current account balances." << endl;
cout << "Press 3. Edit current accounts." << endl;
cout << "Press 4. Edit current balance of an account." << endl;
cin >> choice;
switch(choice)
{
case 1:
cout << "You have chosen to enter a new account." << endl;
total=Acc(AcArray);
break;
case 2:
CBalance(total,AcArray);//call account balance function
break;
case 3:
cout << "would you like to edit Account?";
CBalance(total,AcArray);//Display account numbers
AccEdit(total, AcArray);//Call
break;
case 4:
cout <<"Contents of entire file"<<endl;
Display(total, AcArray);
}
question(AcArray);
}
void question(struct Account AcArray[])
{
int YN;
cout << "Would you like to return to the main menu 1 or 0?";
cin >> YN;
switch(YN)
{
case 1:
menu(AcArray);
break;
case 0:
exit(0);
break;
}
}
void AccEdit(int total, struct Account AcArray[])
{
int acc;
char YN;
cout<<" Enter the Account Number to edit";
cin>>acc;
cout << "Would you like to modify or delete (1 or 0)?";
cin >> YN;
switch(YN)
{
case 1:
modify(acc,total,AcArray);
break;
case 0:
del(acc,total,AcArray);
break;
}
}
void CBalance(int total, struct Account AcArray[])
{
for(int c=0;c<total;c++)
cout << "Customer " << c << " current account balance is $" << AcArray[c].balance << endl;
}
void modify(int acc,int total,struct Account AcArray[])
{
for(int k=0;k<total;k++)
{
if(acc==AcArray[k].account)
{
Load(total,k,AcArray);
cout<<endl<<"Account details modified";
break;
}
}
}
void del(int acc,int total,struct Account AcArray[])
{
for(int c=0;c<total;c++)
{
if(acc==AcArray[c].account)
{
strcpy(AcArray[c].name,"");
strcpy(AcArray[c].city,"");
strcpy(AcArray[c].state,"");
strcpy(AcArray[c].zip,"");
strcpy(AcArray[c].tele,"");
AcArray[c].balance=0;
strcpy(AcArray[c].date,"");
cout<<endl<<"Account deleted";
break;
}
}
}
int Acc(struct Account AcArray[])
{
int total;
cout << "How many account would you like to have?";
cin >> total;
for(int i = 0; i < total; i++)
{
Load(total, i, AcArray);
}
return total;
}
void Load(int total, int c, struct Account AcArray[])
{
cout << "Enter the current account number(i.e 1234) of customer ";
cin >> AcArray[c].account;
cout << endl;
cout << "Enter the full name of customer(First Last) ";
cin >> AcArray[c].name;
cout << endl;
cout << "Enter the Address(i.e. 3470 NW 193 ST) of the customer ";
cin >> AcArray[c].address;
cout << endl;
cout << "Enter the City of customer ";
cin >> AcArray[c].city;
cout << endl;
cout << "Enter the State of customer ";
cin >> AcArray[c].state;
cout << endl;
cout << "Enter the Zip Code of customer ";
cin >> AcArray[c].zip;
cout << endl;
cout << "Enter the Telephone number(i.e 4597894561) of customer ";
cin >> AcArray[c].tele;
cout << endl;
cout << "Enter the current account balance(i.e 789.55) of customer ";
cin >> AcArray[c].balance;
cout << endl;
cout << "Enter the last Day(i.e March 5, 2009) paid by customer ";
cin >> AcArray[c].date;
cout << endl;
}
void Display(int t,struct Account AcArray[])
{
for(int c=0;c<t;c++)
{
cout << " Customer " << c+1 << " Account Number is " << AcArray[c].account << endl;
cout << " Customer " << c+1 << " Name is " << AcArray[c].name << endl;
cout << " Customer " << c+1 << " Address is " << AcArray[c].address << endl;
cout << " Customer " << c+1 << " City is " << AcArray[c].city << endl;
cout << " Customer " << c+1 << " State is " << AcArray[c].state << endl;
cout << " Customer " << c+1 << " Zip Code is " << AcArray[c].zip << endl;
cout << " Customer " <<c+1 << " Telephone number is " << AcArray[c].tele << endl;
cout << " Customer " << c+1 << " current account balance is $" << AcArray[c].balance << endl;
cout << " Customer " << c+1<< " last Day paid is " << AcArray[c].date << endl;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.