jabd123
New member
- Joined
- Dec 5, 2021
- Messages
- 1
- Programming Experience
- 1-3
This is for a user login system which is a small part of a larger project
1. Make the program check the string for uppercase letters, lowercase letters and numbers
2. make it so the username and password are stored together in an array so they can be checked when the user enters the login to check if they match
*codebase is copied at the bottom*
1. Make the program check the string for uppercase letters, lowercase letters and numbers
2. make it so the username and password are stored together in an array so they can be checked when the user enters the login to check if they match
*codebase is copied at the bottom*
C#:
class account
{
protected string username;
protected string password;
protected string password1;
public void createlogin()
{
bool valid = false;
Console.WriteLine("Enter a username ");
username = Console.ReadLine();
do
{
Console.WriteLine("Enter a password with 8 or more characters that contains at least: \n 1 upper case letter\n 1 lowercase letter\n 1 number");
password = Console.ReadLine();
if (password.Length < 8)
{
Console.WriteLine("Your password is less than 8 characters");
valid = false;
}
else
{
valid = true;
}
if (password.Contains("A"))//checks if it contains uppercase letters
{
valid = true;
}
else
{
valid = false;
Console.WriteLine("Your password didn't contain an Uppercase letter\ntry again");
}
if (password.Contains("a"))//checks if it contains lowecase letters
{
valid = true;
}
else
{
valid = false;
Console.WriteLine("Your password didn't contain a lowercase letter\ntry again");
}
} while (valid == false);
valid = false;
do
{
Console.WriteLine("Re-enter your password");
password1 = Console.ReadLine();
if (password != password1)
{
Console.WriteLine("You have entered 2 different password\n please try again");
valid = false;
}
else
{
valid = true;
}
} while (valid == false);
if (valid == true)
{
account[] database = new account[100]; //not sure if this section is correct
account user1 = new account();
database[1] = user1;
}
}
}
Attachments
Last edited by a moderator: