C ++ Program Design Project Development-bank ATM (III)

Source: Internet
Author: User

When the password is entered, the password is limited. If the password is not entered correctly three times, the program will exit and the user is not allowed to continue the operation.

# Include <iostream> # include <string> using namespace std; int main () {string pwd; int cLogin = 0; do {cout <"\ n enter the password: \ n "; cin> pwd; if (pwd! = "123") {cLogin + = 1;} else {cout <"entered correctly! "; Break;} cout <" there are only three chances each day, and today there are still Password Input times: "<3-cLogin <endl ;}while (cLogin <3 ); system ("Pause ");}

Here, the loop can use other functions. I use do {} while (), and The for loop can also be written here. You can try it. After all, the capabilities are limited. If there is something bad to write, you can point it out and learn together. Thank you.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.