LOOPING IN LOG-IN AND MENU THAT I WAS STUCK RIGHT NOW

//*PS. MY CODE WASNT THAT FINISH YET IN MENU OF B,C, AND D*//
#include <iostream>
#include <string>
using namespace std;

int main ()
{
string un,p,choice,tryagain;
int at=0, menu=0;
float fn,sn;

do {

cout<<"\nUsername: ";
cin>>un;
cout<<"Password: ";
cin>>p;

if (un=="parago" && p=="123")
{
do
{
system ("cls");
cout<<"\t\t\t\t\tWELCOME TO ANONG GAGAWIN MO?"
<<"\nA. ADDITION"
<<"\nB. SUBTRACTION"
<<"\nC. MULTIPLICATION"
<<"\nD. DIVISION"
<<"\n\nCHOICE KO AY: ";
cin>>choice;
cout<<endl;


if (choice=="a." || choice=="a" || choice=="A" || choice=="A.")
{
system ("cls");
cout<<"\t\t\tADDITION";
cout<<"\nFirst Number: ";
cin>>fn;
cout<<"Second Number: ";
cin>>sn;
cout<<"\nThe Addition of two number is "
<<fn+sn
<<"\n\nDo you want to choose again?";
cin>>tryagain;

while (tryagain=="Y" || tryagain=="y");
menu++;

system ("pause");
return 0;

}



system ("pause");
return 0;
}
}
else
{
system ("cls");
cout<<"INVALID USERNAME &/ PASSWORD";
at++;
}
}
while (at<3);

system ("cls");
cout<<"SYSTEM BLOCKED"
<<endl;
system ("pause");

}
Last edited on
1. Use [code][/code] tags when you post code (see the <> icon on the right).

2. Use some functions to clean up your main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
bool validate( ) {
    cout<<"\nUsername: ";
    cin>>un;
    cout<<"Password: ";
    cin>>p;
    if (un=="parago" && p=="123")
        return true;
    else
        return false;
}

int main( ) {
   int attempts = 0;
   do {
        if ( validate() ) {
            // call another function
        } else {
            attempts++;
        }
   } while ( attempts < 3 );
}
Topic archived. No new replies allowed.