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; }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment