Log-in Limiter and Asterisk Password Fix :(

Feb 6, 2017 at 7:36am
Hi guys, this might be the last favor I am gonna ask (i know its too much) but can you please point out and fix the problems with this source code. Basically it should automate a login program which has an attempt limiter and if the user and pass is correct it should continue with the program. Thank you very much! Please help me.

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
  
#include<iostream>
#include<string>
#include<stdlib.h>
#include<conio.h>
using namespace std;
int main()
{  
   system ("color 7");
   cout <<"        ****************************************************************      " <<endl;   
   cout <<"        ****************************************************************      " <<endl;  
   cout <<"    *******************     ***     ****     ***     *********************    " <<endl; 
   cout <<"***********************   **  **    ****     ***     *************************" <<endl; 
   cout <<"***********************   **  **    ********     *****************************" <<endl;  
   cout <<"***********************   ******    *********   ******************************" <<endl;   
   cout <<"***********************   ******    *********   ******************************" <<endl;   
   cout <<"******************************************************************************" <<endl;  
   cout <<"******************************************************************************" <<endl;
   cout <<"******************************************************************************" <<endl;   
   cout <<"**     **     **        **        **      **      **   *****   **      *******" <<endl;  
   cout <<"**  ** **     **   **   **        **  ******      **   *****   **      *******" <<endl; 
   cout <<"**     **  ** **     *******   *****      **  **  **   *****   **  **  *******" <<endl; 
   cout <<"**  *****     **   **  *****   *****  ******      **   *****   **      *******" <<endl;  
   cout <<"**  *****     **   ****  ***   *****  ******      **      **   **      *******" <<endl;   
   cout <<"******************************************************************************" <<endl;   
   cout <<"******************************************************************************" <<endl;  
   cout <<"******************************************************************************" <<endl;
   cout <<"******************************************************************************" <<endl;
   cout <<"      ******************************************************************      " <<endl;
   cout <<endl;
   cout <<endl;
   
   const int max_attempts=3;
   string username;
   string password;
   char c;
   int attempts = 0;
   
  for(int attempts = 0; attempts < max_attempts; attempts++)
  {
   START:
   cout <<"                               User has 3 trials" <<endl;
   cout <<"                    Enter Username: ";
   cin >>username;
   cout <<"                    Enter Password: ";
    char pass[32];
   int i = 0;
   char a;
   for (i=0;;)
   {
   	a=getch();
   	
   	if((a>='a'&&a<='z')||(a>='A'&&a<='Z')||(a>='0'&&a<='9'))
   {
   	pass[i]=a;
   	++i;
   	cout<<"*";
   }
   if(a=='\b'&&i>=1)
   {
   	cout<<"\b \b";
   	--i;
   }
   if (a=='\r')
   {
   	pass[i]='\0';
   	break;
   }
}

    if (username=="1234" || password=="12345")
        {goto loop2;}
    else{
        cout << "Unsuccessful login " << max_attempts - attempts - 1 << " attempts more.\n";
    }
   
   
        

   
   
       
          system("cls");
   loop2:
   string answer;             
   cout <<"                             MAIN MENU\n";
   cout <<"\nchoose the letter for each topic to view some sample program: \nBasic in c++: ";
   cout <<"          \n a.variables";
   cout <<"          \n b.constant";
   cout <<"          \n c.operators";
   cout <<"          \n d.basic input/output";
   cout <<"          \n e.control structure";
   cout <<"          \n f.arrays";
   cout <<"          \n g.Exit" ;
   cout <<endl;
   cout <<endl;
   cout <<"Please Enter the letter you choose: ";
   cin >> answer;



   if(answer == "a")
   {      
          system("cls");
   string variable;         
   cout <<"VARIABLE in C++ is name for a piece of memory that can be used to store informa-tion" <<endl;
   cout <<"          \n a. identifier, data types, declaration, and introduction of variables";
   cout <<"          \n b. introduction of strings";
   cout <<"          \n c. go back to main menu";
   cout <<"          \n d. Exit";
   cout <<endl;
   cout <<"Please Enter the letter you choose: ";
   cin >>variable;
                 
                    }
                    
                    
   if(answer == "b")
   {
   string constant;
   cout <<"CONSTANT expression with a fixed value" <<endl;}
                     


              
}
   
   
system ("PAUSE");
return 0; 
}
Feb 6, 2017 at 7:38am
What are your specific assignment details? What is your program like?
Feb 8, 2017 at 12:35am
Well asa you can see on the 2nd part it is the MENU already. I am only having problems with the login/authentication part and the looping structure.
Topic archived. No new replies allowed.