Error on switch loop. Need Help! Only a few hours left

Can anyone help me in debugging this program?
go to the url.. the code is too long to fit in here

cpp.sh/4lio7
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
int main()
{

      char uname[20];
      char userpassword[20];
      char user2[20]; char password2[20];
      char name[20];
         char address[20];
         char tc[4];
         char twn[20];
         char cty[20];
         int phnumber;
         char dob[20];
         int a;
         char nationalityproof[20];
         int choice;
         int choice2;


      cout<<"Welcome to the Social Security Program. \n"
         <<"If you don't have an account enter the letter 'N' \n"
         <<"\n To begin. Please Login. \n"<<endl;

     User u(uname, userpassword);
     cout<<"Username: \n";
     cin.getline(uname,20);

     if (uname == "N" || "n")
     {
         cout<<"Please enter your new username \n"<<endl;
         cin.getline(user2, 20);
         cout<<endl;
         cout<<"Please enter your new password \n"<<endl;
         cin.getline(password2, 20);
         cout<<endl;
         cout<<"Please wait while your new profile is being created... \n"<<flush;
         u.Create_new_user(user2, password2);
         system("PAUSE");
         system("CLS");
     }
     else
     {
        cout<<"Password: ";
        cin.getline(userpassword,20);
        User u(uname, userpassword);
        u.Login();
     };

         Database d("Luke", "49 Bishop St.", " ", "Belize City", 6629895, "June 1st, 1997", 20);
         d.showmenu();
         cin>>choice;
         while (choice != 4)
         {
            //d.print();
            //d.Agedetermination();
            Database d2(name, address, twn, cty, phnumber, dob, a);
            switch (choice)
            {
            case 1: //adding a new customer

                cout<<"Please enter the customer's name \n";
                cin.getline(name, 20);
                cout<<endl;
                cout<<"Please enter the customer's address \n";
                cin.getline(address, 20);
                cout<<endl;
                cout<<"Does the customer live in a town or city? \n";
                cin.getline(tc, 4);

                if (tc == "town" || "Town" || "TOWN")
                {
                    cout<<"Please enter the customer's town \n";
                    cin.getline(twn, 20);

                }
                else if (tc == "city" || tc == "City" || tc == "CITY")
                {
                    cout<<"Please enter the customer's city \n";
                    cin.getline(cty, 20);
                };

                cout<<"Please enter the customer's phone number \n";
                cin>>phnumber;
                cout<<endl;
                cout<<"Please enter the customer's date of birth \n";
                cin.getline(dob, 20);
                cout<<endl;
                cout<<"Please enter the customer's age \n";
                cin>>a;
                d2.Agedetermination();
                d2.showmenu();
                cin>>choice;
            break;

            case 2: //accessing an existing customer's account
                d2.print();
                d2.showmenu();
                cin>>choice;
            break;

            case 3: //editing an existing customer
                cout<<"Would you like to edit all information of the customer? \n"
                    <<"You can also choose to adjust just the customer's name or the customer's address \n"
                    <<"Which option would you like to choose? \n"
                    <<"1. Edit all. \n 2. Edit name \n 3. Edit address \n";
                    AddCustomer ac(name, address, twn, cty, phnumber, dob, a, nationalityproof);
                    if (choice2 = 1)
                    {

                        cout<<"Please enter the customer's name \n";
                        cin.getline(name, 20);
                        cout<<endl;
                        cout<<"Please enter the customer's address \n";
                        cin.getline(address, 20);
                        cout<<endl;
                        cout<<"Does the customer live in a town or city? \n";
                        cin.getline(tc, 4);

                        if (tc == "town" || "Town" || "TOWN")
                        {
                            cout<<"Please enter the customer's town \n";
                            cin.getline(twn, 20);

                        }
                        else if (tc == "city" || tc == "City" || tc == "CITY")
                        {
                            cout<<"Please enter the customer's city \n";
                            cin.getline(cty, 20);
                        };

                        cout<<"Please enter the customer's phone number \n";
                        cin>>phnumber;
                        cout<<endl;
                        cout<<"Please enter the customer's date of birth \n";
                        cin.getline(dob, 20);
                        cout<<endl;
                        cout<<"Please enter the customer's age \n";
                        cin>>a;
                        cout<<"Please enter the customer's nationality \n";
                        cin.getline(nationalityproof, 20);
                        ac.showmenu();
                        cin>>choice;

                    }
                    else if (choice2 = 2)
                    {
                        //changing customer's name
                        cout<<"Please enter the new name of the customer you would like to change \n";
                        cin>>name;
                        ac.namechange(name);
                    }
                    else if (choice2 = 3)
                    {
                        //changing customer's address
                        cout<<"Please enter the new address of the customer you would like to change \n";
                        cin>>address;
                        ac.addresschange(address);
                    };
                    cout<<endl;
                    cout<<"Please wait while changes are being made... \n"<<endl;
                    ac.print();
                    ac.showmenu();
                    cin>>choice;
                break;
            default: cout<<"Error! This is not an option \n Please try again \n";
            }


            cout<<"Thank you for using our Social Security Software. \n";





         };


    cout<<"Would you like to log out? \n";
    char response[3];
    cin.getline(response,3);
    if (response == "yes" || response == "Yes" || response == "Y" || response == "y")
    {
        cout<<"Good bye \n";
    }
    else
    {
      d.showmenu();
      cin>>choice;
    }


    return 0;
}
Last edited on
Line 258 if (choice2 = 1)

Also, try encasing your case with brackets.


EDIT:
Also, do you have your AddCustomer::print() func implemented?
Last edited on
Can you explain as to what you mean by encasing?
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
if (choice2 = 1)
                    {

                        cout<<"Please enter the customer's name \n";
                        cin.getline(name, 20);
                        cout<<endl;
                        cout<<"Please enter the customer's address \n";
                        cin.getline(address, 20);
                        cout<<endl;
                        cout<<"Does the customer live in a town or city? \n";
                        cin.getline(tc, 4);

                        if (tc == "town" || "Town" || "TOWN")
                        {
                            cout<<"Please enter the customer's town \n";
                            cin.getline(twn, 20);

                        }
                        else if (tc == "city" || tc == "City" || tc == "CITY")
                        {
                            cout<<"Please enter the customer's city \n";
                            cin.getline(cty, 20);
                        };

                        cout<<"Please enter the customer's phone number \n";
                        cin>>phnumber;
                        cout<<endl;
                        cout<<"Please enter the customer's date of birth \n";
                        cin.getline(dob, 20);
                        cout<<endl;
                        cout<<"Please enter the customer's age \n";
                        cin>>a;
                        cout<<"Please enter the customer's nationality \n";
                        cin.getline(nationalityproof, 20);
                        ac.showmenu();
                        cin>>choice;

                    }
                    else if (choice2 = 2)
                    {
                        //changing customer's name
                        cout<<"Please enter the new name of the customer you would like to change \n";
                        cin>>name;
                        ac.namechange(name);
                    }
                    else if (choice2 = 3)
                    {
                        //changing customer's address
                        cout<<"Please enter the new address of the customer you would like to change \n";
                        cin>>address;
                        ac.addresschange(address);
                    };


how can i encase it? i tried improving it, no luck.
Just surround them with brackets

1
2
3
4
case 1:
{
     //....
}


It should be
if (choice2 == 1)
Not
if (choice2 = 1)
Last edited on
okay, thanks. You were alot of help

i also found an error where

1
2
3
4
5
void AddCustomer::print()
{
    
    
}


wasn't included. Thanks alot
Topic archived. No new replies allowed.