The No Interest Credit Company provides zero-interest loans to customers. Design an application that gets customer account data, including an account number, customer name, and balance due. Output the account number and name, then output the customer's projected balance each month for the next 10 months. Assume that there is no finance charge on this account, that the customer makes no new purchases, and that the customer pays off the balance with equal monthly payments, which are 10 percent of the original bill.

1 answer

Here's a nice little perl program. I'm sure you can modify it for the language of your choice.

#pay off a loan in 10 equal payments, except for possibly the last, due to roundoff.
print "Customer name: "; my $name = <STDIN>; chomp $name;
print "Account Number: "; my $account = <STDIN>; chomp $account;
print "Balance: \$"; my $balance = <STDIN>; chomp $balance;

my $n = 10;
my $payment = $balance*(1.0/$n);
# round payment up to nearest cent, to ensure payoff in 10 payments.
$payment = int($payment*1000);
$payment+=10 if $payment%10 != 0;
$payment = int($payment/10) * 0.01;

print "\n\nAccount Number: $account\n";
print "Customer Name: $name\n";
printf "Balance: \$%4.2f\n",$balance;
printf "Payment: \$%4.2f\n",$payment;

print "Pmt Balance\n";
my $bal = $balance;
for (my $i = 1; $i < $n ; $i++) {
$bal -= $payment;
printf "%2d %8.2f\n",$i,$bal;
}
printf "%2d %8.2f\n",$n,0;

OUTPUT IS BELOW

Customer name: Bull Durham
Account Number: 18971AC
Balance: $12434.72

Account Number: 18971AC
Customer Name: Bull Durham
Balance: $12434.72
Payment: $1243.48
Pmt Balance
1 11191.24
2 9947.76
3 8704.28
4 7460.80
5 6217.32
6 4973.84
7 3730.36
8 2486.88
9 1243.40
10 0.00