🔒 Closed JAVA OOP

Status
Not open for further replies.

NAMII-CHAN

Eternal Poster
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;
}
 
Status
Not open for further replies.

About this Thread

  • 1
    Replies
  • 555
    Views
  • 2
    Participants
Last reply from:
PHC-LEIIKUN

Trending Topics

Online now

Members online
1,273
Guests online
2,354
Total visitors
3,627

Forum statistics

Threads
2,292,781
Posts
29,079,522
Members
1,209,491
Latest member
smweedevday
Back
Top