Saturday, August 18, 2018

EMI CALCULATOR USING STRUCTURE

  • Problem Description

    1. Create a Structure called "EMI" and declare three variables as principal(float), rate(float), time(float)

    2. Create a structure variable as "e"

    3. Input the principal, rate and time.

    4. Calculate the EMI to be paid and the formula is as follows:


    One Month interest = rate=rate/(12*100)
    One Month Period = time=time*12

    totalemi= (principal*rate*pow(1+rate,time))/(pow(1+rate,time)-1)

    5. Print the final EMI
  • CODING ARENA
  • #include <stdio.h>
    #include <math.h>
    struct EMI
    {
      float principal, rate, time, totalemi;
      }e; 
    int main()
    {
      scanf("%f",&e.principal);
      scanf("%f",&e.rate);
      scanf("%f",&e.time);
      e.rate=e.rate/(12*100);
      e.time=e.time*12;
      e.totalemi=            (e.principal*e.rate*pow(1+e.rate,e.time))/(pow(1+e.rate,e.time)-1);
      printf("Monthly EMI is=%.2f ",e.totalemi);
      return (0);
    }
      
  • Test Case 1

    Input (stdin)
    200000
    
    10
    
    2
    
    
    Expected Output
    Monthly EMI is=9228.99
  • Test Case 2

    Input (stdin)
    400000
    
    15
    
    2
    
    
    Expected Output
    Monthly EMI is=19394.60

No comments:

Post a Comment