Answer to Question #318487 in C++ for tom

Question #318487

Suppose that the rent for an apartment is $1000 per month this year and increases 3% every year. Write a C++ program that computes the rent in five years and the total rent for one year starting five years from now


1
Expert's answer
2022-03-26T05:45:35-0400
#include <iostream>
#include <iomanip>
using namespace std;


int main() {
    double rent_per_month = 1000;
    double increase = 0.03;
    double total = 0;
    int n=5;


    for (int i=0; i<n; i++) {
        total += 12*rent_per_month;
        rent_per_month *= 1 + increase;
    }
    cout << fixed << setprecision(2) << "The total rent for "
         << n << " yeas will be $" << total << endl;
    cout << "The moth rent after " << n << " years from now "
         << "will be $" << rent_per_month;


    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog