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

Use Javascript Objects Only (Check Protection) Computers are frequently employed

ID: 3676681 • Letter: U

Question

Use Javascript Objects Only

(Check Protection) Computers are frequently employed in check-writing systems such as payroll and accounts payable applications. Many strange stories circulate regarding weekly paychecks being printed (by mistake) for amounts in excess of $1 million. Incorrect amounts are printed by computerized check-writing systems because of human error and/or machine failure. Systems designers build controls into their systems to prevent erroneous checks from being issued.Another serious problem is the intentional alteration of a check amount by someone who intends to cash a check fraudulently. To prevent a dollar amount from being altered, most computerized check-writing systems employ a technique called check protection.

Checks designed for imprinting by computer contain a fixed number of spaces in which the computer may print an amount. Suppose a paycheck contains eight blank spaces in which the computer is supposed to print the amount of a weekly paycheck. If the amount is large, then all eight of those spaces will be filled, for example:

1,230.60 (check amount)

--------

12345678 (position numbers)

On the other hand, if the amount is less than $1000, then several of the spaces will ordinarily be left blank. For example,

   99.87

--------

12345678

contains three blank spaces. If a check is printed with blank spaces, it’s easier for someone to alter the amount of the check. To prevent a check from being altered, many check-writing systems insert leading asterisks to protect the amount as follows:

***99.87

--------

12345678

Write a script that inputs a dollar amount to be printed on a check, then prints the amount in check-protected format with leading asterisks if necessary. Assume that nine spaces are available for printing the amount.

Explanation / Answer

Hi I know it's a JAVA Script forum, but I have just created something in C++ which you may find useful,.

#include <iostream>

using namespace std;

int main()

{

char amount[10];

int length = 0;

int dollars = 0;

cout<< "Please enter the check amount: " << endl;

cin>> amount;

while((amount[length] != '.') && (amount[length] !=''))

{

dollars = (dollars * 10) + amount[length]-48;

length++;

}

if (dollars > 19)

switch(dollars/10)

{

case 2 : cout<< "TWENTY ";

break;

case 3 : cout<<"THIRTY ";

break;

case 4 : cout<<"FOURTY ";

break;

case 5 : cout<<"FIFTY ";

break;

case 6 : cout<<"SIXTY ";

break;

case 7 : cout<<"SEVENTY ";

break;

case 8 : cout<<"EIGHTY ";

break;

case 9 : cout<<"NINETY ";

break;

}

else if (dollars > 9)

{

switch(dollars)

{

case 10 : cout<<"TEN";

break;

case 11 : cout<<"ELEVEN";

break;

case 12 : cout<<"TWELVE";

break;

case 13 : cout<<"THIRTEEN";

break;

case 14 : cout<<"FOURTEEN";

break;

case 15 : cout<<"FIFTEEN";

break;

case 16 : cout<<"SIXTEEN";

break;

case 17 : cout<<"SEVENTEEN";

break;

case 18 : cout<<"EIGHTEEN";

break;

case 19 : cout<<"NINETEEN";

break;

}

dollars = 0;

}

// assumes dollars < 1000 by this point

if (dollars > 100)

{

switch (dollars / 100)

{

case 1 : cout<<"ONE";

break;

case 2 : cout<<"TWO";

break;

case 3 : cout<<"THREE";

break;

case 4 : cout<<"FOUR";

break;

case 5 : cout<<"FIVE";

break;

case 6 : cout<<"SIX";

break;

case 7 : cout<<"SEVEN";

break;

case 8 : cout<<"EIGHT";

break;

case 9 : cout<<"NINE";

break;

}

cout << " HUNDRED ";

dollars = dollars % 100;

}

dollars = 0;

while (amount[length] != '')

{

if(amount[length] != '.')

{

dollars = (dollars * 10 + amount[length]-48);

}

length++;

}

if(dollars > 0)

{

cout << " AND " << dollars << "/100" << endl;

}

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