Assembly Language Program Help Banks use a Personal Identication Number (PIN) to
ID: 3763214 • Letter: A
Question
Assembly Language Program Help
Banks use a Personal Identication Number (PIN) to uniquely identify each customer. Let us assume that our bank has a specied range of acceptable values for each digit in its customers’ 5-digit PINs. The table shown below contains the acceptable ranges, where digits are numberedfrom left to right in the PIN. Then we can see that the PIN 52413 is valid. But the PIN 43534 is invalid because the rst digit is out of range. Similarly, 64535 is invalid because of its last digit.
Digit Number Range
1 5 to 9
2 2 to 5
3 4 to 8
4 1 to 4
5 3 to 6
Your task is to create a procedure named Validate_PIN that receives a pointer to an array of byte containing a 5-digit PIN. Declare two arrays to hold the minimum and maximum range values, and use these arrays to validate each digit of the PIN that was passed to the procedure. If any digit is found to be outside its valid range, immediately return the digit’s position (between 1 and 5) in the EAX register. If the entire PIN is valid, return 0 in EAX. Preserve all other register values between calls to the procedure. Write a test program that calls Validate_PIN at least four times, using both valid and invalid byte arrays. By running the program in a debugger, verify that the return value in EAX after each procedure call is valid. Or, if you prefer to use the book’s library, you can display "Valid" or "Invalid" on the console after each procedure call.
Explanation / Answer
#include <iomanip>
#include <string>
#include <fstream>
using namespace std;
void getName(string);
void getPin(int,int);
void displayMenu(int);
string name;
int pin1, pin2, ch ;
int main()
{
cout << fixed << showpoint << setprecision(2);
getName(name);
getPin(pin1,pin2);
displayMenu(ch );
system("pause");
}
void getName(string name)
{
cout << "Enter your name: ";
cin >> name;
if (name = "AXBY") || (name != "ABGSHY"))
{
getName(name);
}
}
void getPin(int pin1, int pin2)
{
string name;
if (name == "AXBY")
{
cout << "Please Enter Pin: ";
cin >> pin1;
if (pin1 != 4433)
{
cout << "Pin incorrect please try again!";
cin >> pin1;
}
}
if (name == "ABGSHY")
{
cout << "Please Enter Pin: ";
cin >> pin2;
if (pin2 != 2849)
{
cout << "Pin incorrect please try again!";
cin >> pin2;
}
}
}
void displayMenu(int ch )
{
cout << "[1] Check your account Balance "
"[2] Withdraw funds "
"[3] Deposit funds "
"Please Enter Choice: ";
cin >> ch ;
if (ch != 1 || ch != 2 || ch != 3)
{
cout << "Choice is incorrect, enter choice now: ";
cin >> ch ;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.