5. Write a C++ program for cell phone PIN. If the user entered the correct pin code, display “Welcome to SGS Telecom”. The cell phone user will enter his pin code three times; if on third try he fails to enter the correct pin code, display “Invalid Pin Code”. Thereafter, the program will prompt the user to enter PUK secret code for three times also. If the user still fails to enter PUK code after three tries, display “SIM BLOCKED” (PIN= 0123 & PUK = 1234)
1
Expert's answer
2012-09-25T12:12:59-0400
#include <iostream> using namespace std; #include <string> int main(){ int i = 3; string pin; do { & i--; & if (i<2) cout<<"Invalid PIN code\n"; & & cout<<"Enter PIN code\n"; & cin>>pin; } while (pin != "0123" && i > 0);
if (i == 0) { & i = 3; & pin = "0"; & do & { & i--; & if (i<2) cout<<"Invalid PUK code\n"; & else if (i == 0) break; & cout<<"Enter PUK code\n"; & cin>>pin; & } while (pin != "1234" && i > 0); }
if (i == 0) cout<< "SIM BLOCKED\n";
else cout<<"Welcome to SGS Telecom\n"; system("pause"); return 0; }
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments