C-Prec Program Exam # 1 : (You are to write the full program) Write S20000.00 af
ID: 3906490 • Letter: C
Question
C-Prec Program Exam # 1 : (You are to write the full program) Write S20000.00 after the first, second and third payments. You choose the interest rate. Assume simple interest for this example a program that calculates the remaining balance on a loan of Print out the amount of the starting loan Print out the interest rate for the year Print out the monthly payment Print out the balance after the first payment Print out the balance after the second payment Print out the balance after the third payment Note: balance is decreased by the amount of the payment but increased by the balance times the monthly interest rate.Explanation / Answer
Below is the solution:
#include <stdio.h>
int main(void)
{
//loan to input loan amount, balance loan, variables
float loan, balance, interest_rate, monthly_rate, payment;
printf(" Enter Loan Amount: "); //Enter loan amount
scanf("%f", &loan);
balance = loan;
printf("Enter Interest Rate: "); //Enter Interest Rate
scanf("%f", &interest_rate);
monthly_rate = (interest_rate / 100.0f) / 12; //Calculate the monthly rate
printf("Enter monthly payment: "); //Enter the monthly payment
scanf("%f", &payment);
//Calculate the first month payment
balance = (balance - payment) + (balance * monthly_rate);
printf(" Balance remaining after first payment: $%.2f ", balance); //Prints the First month remaining balance
//Calculate the second month payment
balance = (balance - payment) + (balance * monthly_rate);
printf("Balance remaining after second payment : $%.2f ", balance); //Prints the Second month remaining balance
//Calculate the third month payment
balance = (balance - payment) + (balance * monthly_rate);
printf("Balance remaining after third payment: $%.2f ", balance); //Prints the Third month remaining balance
return 0;
}
sample output:
Enter Loan Amount: 20000
Enter Interest Rate: 10
Enter monthly payment: 2000
Balance remaining after first payment: $18166.67
Balance remaining after second payment : $16318.05
Balance remaining after third payment: $14454.04
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.