What's new

JAVA OOP

Jinarfia

Honorary Poster
Joined
Sep 10, 2020
Posts
149
Reaction
18
Points
160
Sino po may alam dito?. Tambak kami sa coding activities ngayooon huhu sana may makatulong

Interest is compounded annually at 10% by a certain bank. Make a program that would
input an amount and a number of years (the program should test that both are positive)
and output how much the original amount will be worth after that period.
 
C++:
#include<stdio.h>
#include<math.h>

int main()
{
        float interest_rate = 0.10;//10%
        float amount;
        int numberOfYears;
        printf("Enter Amount: ");
        scanf("%f", &amount);
        printf("Enter Number of Years: ");
        scanf("%d", &numberOfYears);

        //calculating compound interest

        float finalAmount = (amount * pow((1 + interest_rate), numberOfYears) - 1);
        printf("Final Amount: $ %.2f\n",finalAmount);
        return 0;
}
 

Similar threads

Back
Top