#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
SetConsoleOutputCP(1252); //gör det möjligt att skriva ut å,ä och ö med hjälp av windows.h biblioteket.
cout << "Ange hur mycket du vill sätta in varje år: ";
int deposit;
cin >> deposit;
cout << "Ange ditt sparmål: ";
int targetBalance;
cin >> targetBalance;
cout << "Ange räntesatsen i procent: ";
float interestPercent;
cin >> interestPercent;
interestPercent /= 100;
int years = 0;
double balance = 0;
while (balance < targetBalance)
{
double interest = balance * interestPercent;
balance += interest;
balance += deposit;
cout << balance << "\n"; //Använd för att se vad balance är efter varje loop.
years++;
}
cout << "\nDitt sparmål uppnås efter " << years << " år.\n";
cout << "Ditt saldo kommer då att vara " << balance << " kr.";
return 0;
}