kurtrussel
Honorary Poster
- Joined
- Jun 17, 2013
- Posts
- 398
- Reaction
- 51
- Points
- 140
- Age
- 27
Log-in system sya na nag-gegenerate ng password gamit yung username at birthday ng user.
Sana may makatulong paps
Sana may makatulong paps
written in c/c++? Use standard input/output to get username and birthdate tapos concatenate mo nlng.
ito yung codes ko mga master#include<iostream>
#include<conio.h>
using namespace std;
int bday, yr, pass, mod, size=0, passin, error=0, error1=0, age, opt;
char fn[25], ln[25], mn[25], mnth[25], userin[10], user[25];
int main(){
reg:{
system("cls");
cout<<endl<<"\n\n\t\t\tR E G I S T E R"<<endl;
cout<<"\n First Name: ";
cin>>fn;
cout<<" Last Name: ";
cin>>ln;
cout<<" Middle Name: ";
cin>>mn;
cout<<"\n\tBirthdate"<<endl<<"\n Month: ";
cin>>mnth;
cout<<" Day: ";
cin>>bday;
cout<<" Year: ";
cin>>yr;
cout<<"\n Input Password: ";
cin>>pass;
}
mod = ((pass % 10000) / (pass / 10000));
for(int a=0;a<=24;a++){
if(ln[a]==0){
size++;
}
}
size = 25 - size;
user[0] = fn[0];
user[1] = fn[1];
user[2] = fn[2];
user[3] = ln[size-3];
user[4] = ln[size-2];
user[5] = ln[size-1];
if(mod>=100){
user[6] = (mod / 100) + 48;
user[7] = ((mod / 10) % 10) + 48;
user[8] = (mod % 10) + 48;
}
else {
user[6] = (mod / 10) + 48;
user[7] = (mod % 10) + 48;
}
system("cls");
cout<<endl<<"\n\n\t\t\tL O G I N"<<endl;
cout<<"\n Your Username was generated as "<<user;
login:{
cout<<"\n Enter Username: ";
cin>>userin;
cout<<"\n Enter Password: ";
cin>>passin;
for(int a=0;a<=10;a++){
if(userin[a]!=user[a]){
error1++;
}
}
if(passin!=pass){
error++;
}
if(error1!=0&&error!=0){
cout<<"\n Access Denied!";
cout<<"\n Username and Password Incorrect.";
getch();
return 0;
}
else if(error1!=0){
cout<<"\n Access Denied!";
cout<<"\n Incorrect Username.";
getch();
return 0;
}
else if(error!=0){
cout<<"\n Access Denied!";
cout<<"\n Incorrect Password.";
getch();
return 0;
}
else{
system("cls");
cout<<"\n\n\t\t Access Granted!";
getch();
goto home;
}
}
home:
{
system("cls");
cout<<"\n Name: "<<fn<<" "<<mn<<" "<<ln;
cout<<"\n Birthday: "<<mnth<<" "<<bday<<", "<<yr;
cout<<"\n Choose an option: \n";
cout<<" Option [1] to add new data \n";
cout<<" Option [2] to edit data \n";
cout<<" Option [3] to delete data \n";
cout<<" Option [4] to terminate the program \n"<<endl;
cout<<" Option :";
cin>>opt;
if(opt=1){
goto reg;
}
else if(opt=2){
goto edit;
}
else if(opt=3){
goto del;
}
else if(opt=4){
return 0;
}
else {
system("cls");
cout<<"\n\n\t\tInvalid Input.";
getch();
return 0;
}
}
edit:
{
system("cls");
cout<<"\n\n Choose data to update"<<endl;
cout<<" First data"<<1<<endl;
cout<<"Type[1] to Enter your First name: \n";
cout<<"Type[2] to Enter your Last name: \n";
cout<<"Type[3] to Enter your Middle name: \n";
cout<<"Type[4] to Enter your Age: \n";
cout<<"Type[5] to Enter your Password: \n";
cout<<"Type[6] to Enter your Birthday: \n";
cin>>choose;
}
del:
{
system("cls");
cout<<"\n\n Choose data to delete"<<endl;
cout<<" [1] to delete first name \n";
cout<<" [2] to delete last name \n";
cout<<" [3] to delete middle name \n";
cout<<" [4] to delete age \n";
cout<<" [5] to delete password \n";
cout<<" [6] to birthday \n";
cout<<"\n Delete: ";
}
getch();
}
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
using namespace std;
struct Account
{
string firstName;
string middleName;
string lastName;
int birthYear;
int birthMonth;
int birthDay;
string username;
string password;
};
struct Account accounts[100];
int accountIndex = 0;
void LoginAccount();
Account RegisterAccount();
int main(int argc, char** argv) {
char userInput;
int whileFlag = 1;
while(whileFlag == 1)
{
cout<< "MENU:\n";
cout<< "[A] Login\n";
cout<< "[B] Register\n";
cout<< "[X] Exit\n";
cout<< "Input: ";
cin >> userInput;
switch(userInput)
{
case 'A':
case 'a':
LoginAccount();
break;
case 'B':
case 'b':
accounts[accountIndex] = RegisterAccount();
accountIndex++;
cout<< "\n\nRegister Complete! Please enter any key to go to Menu...";
cin.get();
cin.get();
break;
case 'X':
case 'x':
whileFlag = 0;
break;
default:
cout<< "Invalid input... Please try again.";
}
system("cls");
}
return (EXIT_SUCCESS);
}
void LoginAccount()
{
int successLogin = 0;
string usernameInput = "";
string passwordInput = "";
cout<< "Username: ";
cin >> usernameInput;
cout<< "Password: ";
cin >> passwordInput;
for(int i = 0; i < accountIndex; i++)
{
if(usernameInput == accounts[i].username)
{
if(passwordInput == accounts[i].password)
{
cout<< "Successfully logged in...";
successLogin = 1;
cin.get();
cin.get();
//Show login menu;
}
}
}
if(successLogin == 0)
{
cout<< "Login failed... Please try again...";
cin.get();
cin.get();
}
}
Account RegisterAccount()
{
struct Account newAccount;
system("cls");
cout<< "First Name: ";
cin >> newAccount.firstName;
cout<< "Middle Name: ";
cin >> newAccount.middleName;
cout<< "Last Name: ";
cin >> newAccount.lastName;
cout<< "Birth Year: ";
cin >> newAccount.birthYear;
cout<< "Birth Month (1-12): ";
cin >> newAccount.birthMonth;
cout<< "Birth Day (1-31): ";
cin >> newAccount.birthDay;
cout<< "Password: ";
cin >> newAccount.password;
cout<< "Your username is > ";
//Generate username
cout<< newAccount.firstName << newAccount.birthYear << newAccount.birthMonth << newAccount.birthDay;
newAccount.username = newAccount.firstName + to_string(newAccount.birthYear) +
to_string(newAccount.birthMonth) + to_string(newAccount.birthDay);
return newAccount;
}