Answers for "yearly interest calculator c++ using for loop"

C++
0

yearly interest calculator c++ using for loop

#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

void main()
{
// Inputs //

double princ = 0.0;
double rate = 0.0;
int years = 0;
int year = 1;
double total = 0.0;

// Ask User For INFO //

cout << "What is the principle? ";
cin >> princ;
cout << "What is the rate in decimal? ";
cin >> rate;
cout << "how many years? ";
cin >> years;



for (double total; total = princ*(1+rate)*year;)
{
cout << "The balance after year " << year << " is "<< total << endl << endl;
year += 1;
}

while((years + 1)!= year);

system("pause");
}
Posted by: Guest on July-19-2021

Browse Popular Code Answers by Language