0% found this document useful (0 votes)
2K views

Complete - Computer Programming II

This document is a student's assignment on developing an interest rate calculator in C programming. It includes the code to calculate the monthly payment and total payment for a loan given the loan amount, number of years, and varying annual interest rates from 3.25% to 18% increasing by 0.25% each time. The program uses a do-while loop to repeat the calculations until the user inputs 'N' or 'n' to exit. It provides the output in a table listing the annual interest rate, monthly payment, and total payment for each iteration.

Uploaded by

Benedict Chow
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views

Complete - Computer Programming II

This document is a student's assignment on developing an interest rate calculator in C programming. It includes the code to calculate the monthly payment and total payment for a loan given the loan amount, number of years, and varying annual interest rates from 3.25% to 18% increasing by 0.25% each time. The program uses a do-while loop to repeat the calculations until the user inputs 'N' or 'n' to exit. It provides the output in a table listing the annual interest rate, monthly payment, and total payment for each iteration.

Uploaded by

Benedict Chow
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 8

BACHELOR IN INFORMATION TECHNOLOGY WITH HONOUR

2 / 2019

CBCP 2202

COMPUTER PROGRAMMING II

MATRICULATION NO: 980622145455001


IDENTITY CARD NO. : 980622145455
TELEPHONE NO. : 016-2022183
E-MAIL : [email protected]
LEARNING CENTRE : SEBERANG JAYA

0
INSTRUCTIONS
 Do not copy the assignment question and instructions to your answer.
 Prepare your assignment answer following the layout of the ASSESSMENT
CRITERIA shown in the RUBRICS provided for the course. Where RUBRICS are
not provided, follow the instructions/guidelines specified by the Open University
Malaysia (OUM) for the assignment concerned.
 Your assignment should be written according to the number of words outlined
in the assignment instruction EXCLUDING references.
 Type your answer using 12 point Times New Roman font and 1.5 line spacing.
 Show the number of words at the end of your assignment.
 Tables and figures where provided, should be appropriately titled.
 List your references separately in the APPENDIX page.

1
1.0 Introduction

C Programming is a practical programming language and it was develop by Dennis

Ritchie in the year of 1972. C programming mainly developed as a programming

language to create or write an operating system. The main task for this assignment is

to develop a Interest rate calculator.

Image output 1

2
Image Output 2

3
#include <stdio.h>
#include <math.h>

int main(void) {
// P = Monthly Payment
// A = Loan Amount
// r = Rate of Interest
// N = Number of Payment
// Total Payment

// Variable
char Choose;

// Do while to Continue or exit


do {
// Variable
Int A , N ;

// Variable
double a, b, c, d, P, r = 3.25, MonthlyPayment , Rates, NumberOfYear, TotalPayment;

// Variable
double Increment = 0.25, RateofInterest = 3.25 , Increament = 0.25;

// Output for user


printf("Loan Amount : ");

// Save Input into A


scanf("%d",&A);

// Output for user


printf("Number of Years : ");

// Save Input into N


scanf("%d", &N);

// Print header label for display


printf("Annual Interest Rate \t\t Monthly Payment \t\t Total Payment\n");

// Print header label for display


printf("\t\t\t\t\t\t\t\t\t\t (RM) \t\t\t\t (RM)\n");

// Start for loop 18 times

4
for (int i=0; i<=18 ; i++)
{
// Increament + 0.25 everytime
r += Increment;

// Annual Interest Rate


printf("\n\t\t\t\t%.2f%%",r);

//Rate of interestConvert 3.75% to Decimal Point 0.0375


RateofInterest += Increament;

// r = (Annual Interest Rate / 100) / 12 = 0.002916


Rates = ( RateofInterest / 100) / 12;

// Get Number of year


NumberOfYear = N * 12;

/* Given Formular MonthlyPayment = (r * A ) / ( 1 - ( 1 + r ) ^-60 ) */

// Step 1 : Rate of interest times Loan Amount


a = (Rates * A);

// Step 2 : Plus 1 on Rate of interest


b = 1 + Rates;

// Step 3 : Take Rate of interest time power of - Number of year


c = pow(b , -NumberOfYear);

// Step 4 : Take Rate of interest minus 1


d=1-c;

// Devide Both value


MonthlyPayment = a / d ;

// Print monthly payment


printf("\t\t\t\t\t%.2f", MonthlyPayment);

// Total Payment for entire loan


TotalPayment = MonthlyPayment * NumberOfYear;

// Print total payment


printf("\t\t\t\t %.2f", TotalPayment);
}

// Output for user to select

5
printf ("\n\n Do you want to repeat the operation Y/N: ");
// Input to store
scanf (" %c", &Choose);
}
// Capital or small Capital both will work
while (Choose == 'y' || Choose == 'Y');

6
ATTACHMENT

REFERENCES

You might also like