221k views
0 votes
write a program that reads in initial saving value ( $100 ) and interest rate (use .12 = 12%) per year and then figures out how much will be in the account after 4 months and prints results.

User Lostsource
by
6.3k points

1 Answer

4 votes

Answer:

// here is program in C++.

// include header

#include <bits/stdc++.h>

using namespace std;

// main function

int main()

{

// variables

float ini_sav;

float i_rate;

cout<<"Enter the initial saving:";

// read initial saving

cin>>ini_sav;

cout<<"Enter interest rate:";

// read interest rate

cin>>i_rate;

// account after 4 months

float account=ini_sav+ini_sav*i_rate*(4/float(12));

// print account

cout<<"Account after 4 months:"<<account<<endl;

return 0;

}

Step-by-step explanation:

Read initial saving from user and assign it to "ini_sav".Then read interest rate and assign to "i_rate".Then calculate the interest on initial saving after 4 months as "ini_sav*i_rate*(4/float(12))" and to initial saving.This will be the account after 4 months.

Output:

Enter the initial saving:100

Enter interest rate:.12

Account after 4 months:104

User Hennson
by
5.6k points