Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a program that will perform the following tasks: Create a variable that w

ID: 3849631 • Letter: C

Question

Create a program that will perform the following tasks:

Create a variable that will store the user's password (user password is cit142)

Create a variable that will store the user's ID (userID is: fjones)

The program will ask the user to enter thier userid

The program will ask the user to enter their password

The program will test the user input. If the userID AND password matches "you may enter" is displayed. If the passwords do not match "wrong password" is displayed.

The language is C++ and we're using the Dev-C++ application.

Explanation / Answer

Code:
// password verification program
#include <iostream>
#include <string>
using namespace std;

int main()
{
// initializing userid and passwd variables   
string userid = "cit142";
string passwd = "fjones";
// declaring user input user id and password
string uid, password;
  
cout << " Enter the userid : ";
cin >> uid;
cout << " Enter the password : ";
cin >> password;
  
// checking if userid and password entered is correct
if(userid.compare(uid) == 0 && passwd.compare(password) == 0)
cout << " You may enter...";
else
cout << " wrong password";
  
return 0;
}

Execution and output:
Enter the userid : krishna

Enter the password : fjones

wrong password

Enter the userid : cit142

Enter the password : fjones

You may enter...

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote