This assignment is a continuation from the previous assignment of CBCP2101. You are required to accomplish the assignment by writing complete codes in C language. Read again the following scenario and fulfill requirements in completing the codes.
You are required to analyse a problem to calculate and show the output of an interest-bearing investment. All the investment is interest bearing and compounded quarterly (the interest is calculated and added back to the balance four times a year), and is extended for three years.
The users will input the rate for the investment and show to the users how that investment would progress over the next three years.
A table showing the investment’s history (see Table 1)– starting amount, interest and ending amount – for each quarter of each year is prepared. It should also show the total interest earned in each year as well as over the three years.
The input will consist of an interest rate to be analysed. Anything less than 5 percent or greater than 20 percent will be deemed an unreasonable rate and should be rejected.
The interest is calculated by multiplying the current balance by the rate by the time period, one quarter of a year in this case. A new balance is calculated by adding that interest to the current balance.
Table 1
balance |
yearly_interest |
quarter |
interest |
1031.25 |
31.25 |
1 |
31.25 |
1063.48 |
63.48 |
2 |
32.23 |
1096.71 |
96.71 |
3 |
33.23 |
1130.98 |
130.98 |
4 |
34.27 |
1166.32 |
35.34 |
1 |
35.34 |
1202.77 |
71.79 |
2 |
36.45 |
1240.36 |
109.38 |
3 |
37.59 |
1279.12 |
148.14 |
4 |
38.76 |
1319.09 |
39.97 |
1 |
39.77 |
1360.31 |
81.19 |
2 |
41.22 |
1402.81 |
123.69 |
3 |
42.50 |
1446.65 |
167.53 |
4 |
43.84 |
The assessment will be based on the following criteria:
- A proper writing of C codes and its structure
- The ability of program to be compiled and executed
- Implementation of correct programming techniques
- Complete documentation and correct submission.
#include <stdio.h>
#include <conio.h>
#include <math.h>
#define N 3
int main()
int i,j;
float irate,investment,curInterest,curInvest,totInterest=0.0; //variable declaration
float getIntRate(); //function declaration
float getAmount();
float findInterest(float amt, float irate);
irate=getIntRate(); //get the interest rate from keyboard
investment=getAmount(); //get the investment amount from keyboard
curInvest=investment; //set the current investment
for(i=1;i<=N;i++) //loop starts upto N years
printf("Year : %dn", i); //print the heading
printf("------------------------nn");
printf("tQuarter Balance Interest Total Interest Totaln");
printf("t=================================================================n");
for(j=1;j<=4;j++) //number of terms
curInterest=findInterest(curInvest,irate); //find the interest rate for the current quarter
totInterest+=curInterest; //update the total interest
printf("t%dt%.2ftt%.2ftt%.2ftt%.2fnn",j,curInvest, curInterest,totInterest,(curInvest+curInterest)); //print the interest details
curInvest=curInvest+curInterest; //update the final total
system("pause"); //wait the keyboard response from user
return 0;
float findInterest(float amt, float irate)
float interest;
interest= (amt * irate) /400.0; //find the interest
return interest;
float getIntRate()
float interest;
while(1)
printf("Enter the interest rate : ");
scanf("%f",&interest); //read the interest rate
if(interest>=5 && interest<=20) //check if the interest rate between 5 and
break; //if the above condition is true, exit from the loop
else
printf("nInvalid interest rate. It should be between 5 and 20n"); //else print the error message
return interest; //return the interest value
float getAmount()
float inv;
while(1
printf("nEnter the Investment Amount : ");
scanf("%f",&inv); //read the investment amount
if(inv>0) //if the investment amount is greater than zero, if yes, exit from the loop
break;
else
printf("nInvalid investment amount. It should be greater than 0n"); //otherwise, print the error message
return inv;
To export a reference to this article please select a referencing stye below:
My Assignment Help. (2021). Calculate And Show Output Of An Interest-Bearing Investment Essay In C Language.. Retrieved from https://myassignmenthelp.com/free-samples/cbcp2202-computer-programming/bearing-investment.html.
"Calculate And Show Output Of An Interest-Bearing Investment Essay In C Language.." My Assignment Help, 2021, https://myassignmenthelp.com/free-samples/cbcp2202-computer-programming/bearing-investment.html.
My Assignment Help (2021) Calculate And Show Output Of An Interest-Bearing Investment Essay In C Language. [Online]. Available from: https://myassignmenthelp.com/free-samples/cbcp2202-computer-programming/bearing-investment.html
[Accessed 27 April 2024].
My Assignment Help. 'Calculate And Show Output Of An Interest-Bearing Investment Essay In C Language.' (My Assignment Help, 2021) <https://myassignmenthelp.com/free-samples/cbcp2202-computer-programming/bearing-investment.html> accessed 27 April 2024.
My Assignment Help. Calculate And Show Output Of An Interest-Bearing Investment Essay In C Language. [Internet]. My Assignment Help. 2021 [cited 27 April 2024]. Available from: https://myassignmenthelp.com/free-samples/cbcp2202-computer-programming/bearing-investment.html.