Untitled
unknown
plain_text
3 years ago
931 B
11
Indexable
#include <iostream> #include <string> using namespace std; int main() { int ID, sum, counter = 1; // The int. that the progrem will use bool wrong_ID = true; // The bool is for the progrem to know when to stop do { cout << "Please enter your ID number : \n"; cin >> ID; // user enter is ID number sum = 0; while (ID > 0) { // The algorithm of the progrem int i = (ID % 10); ID = ID / 10; int j = (ID % 10) * 2; int x = j % 10; int y = j / 10; sum = sum + i + x + y; ID = ID / 10; } if (sum % 10 == 0) wrong_ID = false; else cout << "The ID number you typed is illegal \n"; counter++; // user have only 3 opportunities } while (wrong_ID && counter <= 3); if (wrong_ID) cout << "You typed illegal ID number for too many times \n"; else cout << "Your account is now open! \n"; }
Editor is loading...