Question

Using C++ emulate a sign in procedure. At this stage we do not have a file...

Using C++ emulate a sign in procedure.

At this stage we do not have a file yet that contains those username and password records.

You'll hard code a user name and password, and using selection and some string manipulation or comparison you'll go through the sign in process with your user.

Some things to consider are: Let us know where we're signing in.

Other interactions return to you a black screen with little other than a cursor.

How is your user going to know that they are signing in at the right place?

Your user may / will not have a clue as to how to use your system - use the space after your Company Heading to explain what they are doing. Notice how precise the screen captions there are. You have to guide your user through the interaction until they are familiar with the process.

If I try to authenticate as TRAN that the same as tran or TrAN or TraN? Nope. What string manipulations or operations have we seen that you can use here?

Let's assume you can goof your sign in 2 times before you are booted out. You'll need a mechanism to keep track of those failed sign-in attempts.

If you keep all of your previous outputs to screen present, your terminal window will get awfully crowded awfully fast. You'll want to clear the screen in between interactions (like other programs do ) There are two methods here to do so.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

1. Code For Login and Registration System in C++

#include <iostream>
#include<string>
using namespace std;
int failed_login_attempts = 3, failed_correct_password_attempts = 3;
string username, password;
bool new_user = false;
/**
* Function to get username and password
*
* @param null
*
* @return void
*/
void getUserData(){
   cout<<"Enter username"<<endl;
   cin>>username;
   cout<<"Enter password"<<endl;
   cin>>password;
}// end getUserData()

/**
* Function to get username and password and check for valid login to the system
*
* @param null
*
* @return void
*/
void isLoggedIn(){
   login_again:
   // Take Username and password
   getUserData();
   // check for valid user credentials
   if(username == "test"){
       goto old_user_credentials;
       new_user_credentials:
       cout<<"Enter your password again "<<endl;
       cin>>password;
       old_user_credentials:
       if(password == "demo"){
           cout<<"Succesfully logged in"<<endl;
       }else{
           if(new_user == true){
               failed_correct_password_attempts = failed_correct_password_attempts - 1;
               if(failed_correct_password_attempts > 0){
                   cout<<"You have "<<failed_correct_password_attempts<<" attempts left to enter the correct password to sign in to the system"<<endl;  
                   goto new_user_credentials;
               }else{
                   cout<<"Sorry, You have entered invalid password"<<endl;
                   exit(0);
               }
           }else{
               failed_login_attempts = failed_login_attempts - 1;
               if(failed_login_attempts > 0){
                   cout<<"You have "<<failed_login_attempts<<" attempts left to sign in to the system"<<endl;
                   goto login_again;
               }else{
                   cout<<"Sorry, You have entered invalid credentials"<<endl;
                   exit(0);  
               }
           }
       }
   }else{
       failed_login_attempts = failed_login_attempts - 1;
       if(failed_login_attempts > 0){
           cout<<"You have "<<failed_login_attempts<<" attempts left to sign in to the system"<<endl;
           goto login_again;
       }else{
           cout<<"Sorry, You have entered invalid credentials"<<endl;
           exit(0);  
       }
   }
}// end isLoggedIn()

/**
* Function for the starting point of the program in C++
*
* @param null
*
* @return int
*/
int main(int argc, char** argv) {
   int choice;
   cout<<"==================================================================== Simple Login and Registration System =================================================="<<endl;
   // Menu System for Login and Registratio System in C++
   while(true){
       cout<<"1: Login"<<endl;
       cout<<"2: Register"<<endl<<"3: Exit the program"<<endl<<"Enter your choice"<<endl;
       cin>>choice;
       switch(choice){
           case 1 :
               isLoggedIn();
               break;
           case 3 :
               exit(0);
               break;
           case 2 :
               getUserData();
               if (std::string::npos != password.find_first_of("0123456789")) {
                   cout<<"User Registered Successfully"<<endl;
                   new_user = true;
               }else{
                   cout<<"Password must contain a number"<<endl;
               }
               break;
       }
   }
   return 0;
}// end main(int argc, char** argv)

Add a comment
Know the answer?
Add Answer to:
Using C++ emulate a sign in procedure. At this stage we do not have a file...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Hi everyone, For my Assignment I have to use C# in order to create a validation...

    Hi everyone, For my Assignment I have to use C# in order to create a validation form and include the following things to register and validate: Email Address, Username, Password, Retype Password, and a Submit Button. I have figured out some of the code for the Email Address validation: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Validation4 {     public partial class Form1 : Form     {        ...

  • c++ question, i put the txt attachment picture for this question... please include comments on calculations...

    c++ question, i put the txt attachment picture for this question... please include comments on calculations and varibles Description In this program, you will write a program to emulate a vending machine (somewhat). In this version of the program, you will use a struct type defined below struct snackType string name; string code; double price; int remaining; Where name contains the snack's name, code contains the 2 digit code for the item, price holds the item's price, and remaining holds...

  • 1. You are given a C file which contains a partially completed program. Follow the instructions...

    1. You are given a C file which contains a partially completed program. Follow the instructions contained in comments and complete the required functions. You will be rewriting four functions from HW03 (initializeStrings, printStrings, encryptStrings, decryptStrings) using only pointer operations instead of using array operations. In addition to this, you will be writing two new functions (printReversedString, isValidPassword). You should not be using any array operations in any of functions for this assignment. You may use only the strlen() function...

  • I need help modifying this code please ASAP using C++ Here is what I missed on this code below Here are the instruction...

    I need help modifying this code please ASAP using C++ Here is what I missed on this code below Here are the instructions Here is the code Produce correct70 pts O pts Full Marks No Marks results and statisfy requirements view longer Comments 1. Your display amount is not readable 2. I withdraw more than my balance, but I didn't see any error message description Documentations10 pts 0 pts Full Marks No Marks : comment i code and block comment...

  • This is the code we have to edit, i know how to do everything except finding...

    This is the code we have to edit, i know how to do everything except finding if the x and y are in the space, please explain to me when you do the code. We are using addshape() api and more. public class Skeleton { public static void main(String[] args) { //================================ //== Setting up game window ====== SpaceGame myGame; //declaring the object form the class Scanner scan = new Scanner(System.in); System.out.println("What is the window name? "); //window title text...

  • 1. Private data fields: name (of String type, initialized to “Bob”), endurance (of int type, initialized to 4) and happiness (of int type, initialized to 3);

    Language: JAVAPart a: Write a class called Geniegotchi with:1. Private data fields: name (of String type, initialized to “Bob”), endurance (of int type, initialized to 4) and happiness (of int type, initialized to 3);2. Public methods:-void setName(String newName) : renames Genie with newName, printsnewName confirmation to screen;void setName(String newName) : renames Genie with newName, printsnewName confirmation to screen;- intgetEndurance() : returns current endurance;-intgetHappiness() : returns current happiness;-void feed() : this method increases current endurance by 1 if endurance is less...

  • C++. Need some help getting started. We will also have the following two functions: 1. A...

    C++. Need some help getting started. We will also have the following two functions: 1. A mutate function that randomly modifies a chromosome. 2. A crossover function that takes two chromosomes and splits each one at the same spot, then combines them together. Our genetic algorithm works by iterating over generations of chromosomes via the following process: 1. Generate random population. 2. Until we get an answer that is good enough, do the next steps in a loop: (a) Do...

  • Detecting Substrings (C++ Version) Introduction A very common task that is often performed by programs that...

    Detecting Substrings (C++ Version) Introduction A very common task that is often performed by programs that work with text files is the problem of locating a specific substring within the file. I am sure we’ve all done this many times when working with Word, Notepad, or other editors. Since we don’t have a GUI or other means of displaying the contents of a file all at once, let’s modify the problem slightly. Rather than locating a specific substring within a...

  • This is for C++ Write a program that reads in a sequence of characters entered by...

    This is for C++ Write a program that reads in a sequence of characters entered by the user and terminated by a period ('.'). Your program should allow the user to enter multiple lines of input by pressing the enter key at the end of each line. The program should print out a frequency table, sorted in decreasing order by number of occurences, listing each letter that ocurred along with the number of times it occured. All non-alphabetic characters must...

  • In Java(using BlueJ) Purpose Purpose is to practice using file input and output, and array list of objects. Also, this lab specification tells you only what to do, you now have more responsibility to...

    In Java(using BlueJ) Purpose Purpose is to practice using file input and output, and array list of objects. Also, this lab specification tells you only what to do, you now have more responsibility to design how to do it. Problem description You are given a text file called 'Students.txt' that contains information on many students. Your program reads the file, creating many Student objects, all of which will be stored into an array list of Student objects, in the Students...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT