[Solved] Password/Calculator in C# [closed]


For the password validation:
Use a do while loop. The condition to terminate would be if the counter reaches three or if the user gets it right.
example

int counter = 0;
boolean passwordCorrect = false;
do {
    Console.Write("Please enter the password > ");
    passWord = Console.ReadLine();

    //If the password is correct,then it will break the loop
    if (passWord == "1234") {
       passwordCorrect = true;
    }
    counter++;
} while (counter < 3 && !passwordCorrect);

You are not even asking the user if they want to subtract, add,etc.For that, ask the user in the main method. Then you will call that method depending on what they inputed.

Example.

int choice;
Console.Write("What operation would you like to perform?\n1. Addition\2. Subtraction");
Console.Write("\n3. Multiplication\n4. Division");
choice = Console.ReadLine();

switch (choice)
{
    case 1:
        calcAddition();
        break;
    case 2:
        calcSubtraction();
        break;
    case 3:
        calcMultiplication();
        break;
    case 4:
        calcDivision();
        break;
    default:
        Console.Writeline("No operation chosen");
        break;
}

5

solved Password/Calculator in C# [closed]