Intro to C++ programming question Ask the user to information to gain access. Th
ID: 3902407 • Letter: I
Question
Intro to C++ programming question
Ask the user to information to gain access. The only valid combination is "abc", 21 and "qwerty". For example: Gain entry with your user information and password. For security purposes, the information will not be echoed to the screen. Please enter your initials: Please enter your age: Please enter your password: Access granted! OR Gain entry with your user information and password. For security purposes, the information will not be echoed to the screen. Please enter your initials: Please enter your age: Please enter your password Access denied!Explanation / Answer
#include<bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
string str1,str2,str3="abc",str4="qwerty";
int num;
cout << "Gain entry with your user information and password." << endl ;
cout << "For security purposes, the information will not be echoed to the screen." << endl ;
cout << "Please enter your initials:" << endl ;
cin >> str1 ;
cout << "Please enter your age:" << endl ;
cin >> num ;
cout << "Please enter your password" << endl ;
cin >> str2 ;
if(str1.compare(str3)==0&&num==21&&str2.compare(str4)==0)
{
cout << "Access granted!" << endl ;
}
else cout << "Access denied!" << endl ;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.