1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
|
#include <iostream>
using namespace std;
struct CustomerAccount
{
string nameOfCustomer;
string addressOfCustomer;
string city;
string state;
int zip;
long long telephoneNumber;
long double accountBalance;
string dateOfLastPayment;
}account[20];
int inputValues (CustomerAccount *);
void changeValues (CustomerAccount *, int);
void showValues (CustomerAccount *, int);
int main ()
{
string choice, CHOICE;
int Choice, number;
cout << "Would you like to create an account?" << "\n";
cin >> choice;
if (choice == "yes" || choice == "Yes")
number = inputValues (account);
else
return 0;
cout << "Would you like to change the contents of a specific account?" << "\n";
cin >> CHOICE;
if (CHOICE == "yes" || CHOICE == "Yes")
{
cout << "Which account number do you want to change? (1-20)" << "\n";
cin >> Choice;
changeValues(account,Choice);
}
showValues (account,number);
}
void showValues (CustomerAccount * x, int num)
{
for (int n = 0; n <= num; n++)
{
cout << x[n].nameOfCustomer << "\n";
cout << x[n].addressOfCustomer << "\n";
cout << x[n].city << "\n";
cout << x[n].state << "\n";
cout << x[n].zip << "\n";
cout << x[n].telephoneNumber << "\n";
cout << x[n].accountBalance << "\n";
cout << x[n].dateOfLastPayment << "\n";
}
}
void changeValues (CustomerAccount *, int num)
{
cout << "Enter your new name" << "\n";
cin.ignore();
getline (cin, account[num - 1].nameOfCustomer);
cout << "Enter your new street address" << "\n";
cin.ignore();
getline (cin, account[num - 1].addressOfCustomer);
cout << "Enter the new name of your city" << "\n";
cin.ignore();
getline (cin, account[num - 1].city);
cout << "Enter the new name of your state" << "\n";
cin.ignore();
getline (cin, account[num - 1].state);
cout << "Enter your new ZIP code" << "\n";
cin >> account[num - 1].zip;
cout << "Enter your new telephone number" << "\n";
cin >> account[num - 1].telephoneNumber;
cout << "Enter your new account balance" << "\n";
cin >> account[num - 1].accountBalance;
cout << "Enter the date of your last payment" << "\n";
cin.ignore();
getline (cin, account[num - 1].dateOfLastPayment);
}
int inputValues (CustomerAccount *)
{
string choice;
for (int n = 0; n <= 19; n++)
{
cout << "Please enter data about account number ";
cout << (n + 1) << "\n";
cout << "Enter your name" << "\n";
cin.ignore();
getline (cin, account[n].nameOfCustomer);
cout << "Enter your street address" << "\n";
cin.ignore();
getline (cin, account[n].addressOfCustomer);
cout << "Enter the name of your city" << "\n";
cin.ignore();
getline (cin, account[n].city);
cout << "Enter the name of your state" << "\n";
cin.ignore();
getline (cin, account[n].state);
cout << "Enter your ZIP code" << "\n";
cin >> account[n].zip;
cout << "Enter your telephone number" << "\n";
cin >> account[n].telephoneNumber;
cout << "Enter your account balance" << "\n";
cin >> account[n].accountBalance;
cout << "Enter the date of your last payment" << "\n";
cin.ignore();
getline (cin, account[n].dateOfLastPayment);
cout << "Would you like to create another account? (yes/no)";
cin >> choice;
if (choice == "no" || choice == "No")
{
return n;
break;
}
}
}
|