Hi, I am fairly new to C++, and I am getting an infinite loop in this code, and I have no idea why. Basically, my program is to tell me in how many years I can buy the car of my dreams, which costs a certain amount with a certain depreciation rate, with the money I have to invest at a certain interest rate.
Any help with this would be greatly appreciated!!!
#include <iostream>
using namespace std;
int main()
{
float Invest;
float InterestRate;
float CarPrice;
float Depreciation;
float InvestGrow;
float CarDecrease;
int Year = 0;
cout << "Please enter the amount of money you have to invest (in dollars):" << endl;
cin >> Invest;
cout << "Please enter the interest rate earned on the invested amount (in percent):" << endl;
cin >> InterestRate;
cout << "Please enter the current value of your dream car (in dollars): " << endl;
cin >> CarPrice;
cout << "Please enter the depreciation rate for the car (in percent):" << endl;
cin >> Depreciation;
do
{
InvestGrow = (Invest + (Invest * (InterestRate/100)));
CarDecrease = (CarPrice - (CarPrice *(Depreciation/100)));
Year = Year + 1;
cout << "At the end of year " << Year << " you have $" << InvestGrow << "and the car now costs $" << CarDecrease << "." << endl;