Okay this is a program I have to write for my C++ class. I really don't want any comments as to how poor the coding is or some advanced feature that might do it easier. We are supposed to write a program that write makes use of a user defined class, and the program does this I just can't get the marked line to work, my instructor couldn't even figure it out and he's been coding C++ for years. Help!
#include
#include
using namespace std;
class AcctMon
{
private:
string fname, lname;
string address;
string city, state, zip;
float bal;
public:
void PrintLabel(void)
{
cout << fname << " " << lname << endl;
cout << address << endl;
cout << city << ", " << state << " " << zip << endl;
}
void TestZIP(void)
{
string test;
cout << "Enter the test value.";
cin >> test;
if (zip == test)
cout << "The customer lives within the given ZIP code." << endl;
else
cout << "The customer lives outside the given ZIP code." << endl;
}
void CheckBal(void)
{
cout << "The customer's current balance is " << bal << endl;
}
void InputData (void)
{
cout << "Enter the Customer's first name." << endl;
cin >> fname;
cout << "Enter the Customer's last name." << endl;
cin >> lname;
cout << "Enter the Customer's address." << endl;
getline(cin, address);
cout << "Enter the city. " << endl;
cin >> city;
cout << "Enter the state. " << endl;;
cin >> state;
cout << "Enter the Customer's ZIP code. " << endl;
cin >> zip;
cout << "Enter the Customer's beginning balance. " << endl;
cin >> bal;
}
void UpdateBal(void)
{
float newbal, trans;
int choice = 1;
while (choice == 1)
{
cout << "Enter the transaction.(negative value for subtraction)" << endl;
cin >> trans;
newbal = bal + trans;
bal = newbal;
cout << "Customer's new balance = " << bal << endl;
cout << "Select 1 for more transactions, any other number to exit." << endl;
cin >> choice;
}
}
};
void main()
{
int menu = 99;
AcctMon customer;
while(menu!=0)
{
cout << "Select 1 to enter the customer's information." << endl;
cout << "Select 2 to confirm customer's zone" << endl;
cout << "Select 3 to print a mailing label" << endl;
cout << "Select 4 to update the customer's account balance" << endl;
cout << "Select 5 yto check view the customer's current balance." << endl;
cout << "Select 0 to exit" << endl;
cin >> menu;
switch(menu)
{
case 1:
customer.InputData();break;
case 2:
customer.TestZIP();break;
case 3:
customer.PrintLabel();break;
case 4:
customer.UpdateBal(); break;
case 5:
customer.CheckBal();break;
case 0:
break;
default:
cout << "Enter a valid selection.";
};
}
}
Currently, the program goes into a infinite loop after the marked line throws, it shouldn't obviously. My instructor said I can turn it in with that line coded to with no spaces in the particular piece of data, but since it's an address, it really needs to have the spaces.