I am not a programmer by any means, but for my class we havto do this:
Write a program that asks the user to create a username and password for a logon account. Both should be held as a cString. Prompt the user to enter his/her information to “log on” to an account. The username is not case sensitive, but the password is – only display a successful log on message if both pieces of information are entered according to this constraint. After a successful logon, the username in all lowercase letters should be displayed and the password should be shown as a number of ‘*’ equal to the length of the password.
Here's my code so far, and unless someone in my class explains every bit and snip of code that is required, I cannot understand anything.
#include <iostream>
#include <cstring>
usingnamespace std;
int main()
{
char username[11];
char password[11];
int profile = 0;
cout << "Create a username and password: " << endl;
while (profile == 0) //set to '0' by default
{
int checkusername = 0; //set to '0' until the condition is met
int checkpassword = 0; //set to '0' until the condition is met
cout << "Enter your username (Up to 10 characters, letters and numbers only!)" << endl;
cin >> username;
cout << "Enter your password (Up to 10 characters, letters and numbers only!)" << endl;
cin >> password;
//check if the lenght is equal to required size
if (strlen(username) > 10)
{
checkusername = 1;
}
else
{
for(int i = 0; i < strlen(username);i++)
{
if (isalnum(username[i]))
continue;
else
{
checkusername = 1;
break;
}
}
}
//check if password is appropriate leght
if (strlen(password) > 10)
{
checkpassword = 1;
}
else
{
for(int i = 0; i < strlen(password);i++)
{
if(isalnum(password[i]))
continue;
else
{
checkpassword =1;
break;
}
}
}
//End of While Loop//
}
return 0;
}