Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The U.S. Banking System The code assigned to a bank is an eight digit number plu

ID: 3827077 • Letter: T

Question

  The U.S. Banking System  The code assigned to a bank is an eight digit number plus a ninth check digit. To check for validity, the first eight digits are assigned weights (left to right) of 7, 3, and 9 repetitively. Each digit is multiplied by its weight and the products summed. The resulting sum (mod 10) should equal the check digit.  The assigning of weights insures that all single digit errors and most transposition errors are detected.  You should run the program twice, once using a valid bank number, and once using an invalid bank number.     103000648  Chase     103000846  Chase with a transposition error    103000703  Interbank    103001469  Kirkpatrick Bank    103002251  Citizens Bank of Edmond     103002521  Citizens Bank of Edmond with a transposition error     103002691  First Fidelity    103002795  First Commercial Bank with an error    103003632  Banc First    103003687  First Commercial Bank     103013062    "    103013101    "    103013266  PRIME BANK  1016 W Covell Road    103112594  RCB Edmond Road    103112976  Arvest    303085230  Allegiance Credit Union    303085829  Tinker Federal Credit Union     303087995  Mid First     300387995  Mid First with a transposition error    103900036  Bank of Oklahoma    081904808  Bank of America  2145 W Edmond Rd               Spirit Bank  3823 S Boulevard               Farmers & Merchants 121 E Waterloo               Legacy  1289 E 15               Bank of Nichols Hills    Sample Logic:   read in a bank number   write the bank number, and the multipliers    compute the checksum     loop 8 times using i as a control variable       pick off the i'th digit         ch = bank number[i]          digit[i]  = ch-48;       multiply it by the appropriate weight       print the product       add the product to the subtotal       save the subtotal in an array (in subtotal[i])      end loop   loop 8 times printing the subtotals   print the last subtotal computed   compute the check digit   print the check digit    if the subtotal % 10 == the last digit   then     write 'the check code is valid'   else     write 'the check code is invalid'   Sample output:   - print these numbers - -     don't print these words   1  0  3  0  0  0  6  4  8     bank number   7  3  9  7  3  9  7  3        multipliers   7  0 27  0  0  0 42 12        products   7  7 34 34 34 34 76 88        subtotals   88                            sum   8                             check digit   the check code is valid 

Explanation / Answer

#include <iostream>

int main()
{
   //variables
   unsigned short bankNumber[9], multipliers[8] = {7, 3, 9, 7, 3, 9, 7, 3}
       , products[8] = {0}, subtotals[8] = {0}, sum = 0, checkDigit;

   //Reading the bank number by digits in array
   for (int i = 0; i < 9; ++i) std::cin >> bankNumber[i];
   std::cout << ' ';

   //Writing Multipliers
   for (int i = 0; i < 8; ++i) std::cout << multipliers[i] << ' ';
   std::cout << ' ';

   //Generating products
   for (int i = 0; i < 8; ++i)
   {
       products[i] = bankNumber[i] * multipliers[i];
       std::cout << products[i] << ' ';
   }
   std::cout << ' ';

   //Generating Subtotals
   subtotals[0] = products[0];
   std::cout << subtotals[0] << ' ';
   for (int i = 1; i < 8; ++i)
   {
       subtotals[i] = subtotals[i-1] + products[i];
       std::cout << subtotals[i] << ' ';
   }

   //generation of last check digit
   sum = subtotals[7];
   checkDigit = sum%10;
   std::cout << ' ' << sum << ' ' << checkDigit << ' ' ;

   //checking the validity of code
   if(checkDigit == bankNumber[8]) std::cout << "the code is valid" << ' ';
   else std::cout << "the code is invalid" << ' ';

   return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote