my first task and I need help as it shuts down immediately after I have answered how do I get it not to shut down automatically? I have onöy read c++ for 3 weeks som im a freshy on this be kind
Put the#include <iostream>
usingnamespace std;
int main()
{ //skriver ner alla variabler vi behöver i början
float deposit; // insättning
float target; // Sparmål
float interest; // Ränta
float balance; // Saldo
int yearCount; // Antal år
while (true) {
cout << "Ange hur mycket du vill s\x84tta in varje \x86r:";
cin >> deposit;
if (deposit > 0) {
break;
}
cout << "Ins\x84ttning per \x86r m\x86ste \x94verstiga 0 kr" << end1;
}
while (true) {
cout << "Ange ditt sparm\x86l:";
cin >> target;
if (target > 0) {
break;
}
cout << "Sparm\x86l m\x86ste \x94verstiga 0 kr" << end1;
}
while (true) {
cout << "Ange r\x84ntesats i procent:";
cin >> interest;
if (interest > 0) {
break;
}
cout << "R\x84ntesatsen m\x86ste \x94verstiga 0 kr" << end1;
}
interest = interest / 100,0f + 1,0f; //startvärden på variablarna
balance = deposit;
yearCount = 1; // yearCount är en int alltså heltal därför skriver vi en etta här
while (balance < target) //Så länge saldot är mindre än sparmålet så:
{
balance *= interest; //multiplicerar totala saldot med räntesatsen
balance += deposit; //lägger till en årlig insättning
yearCount++; // plussar på ett år
}
cout << balance;
cout << yearCount;
cin.get();
return 0;
} code you need help with here.
you can do it for input/output but I am not sure you can do it in the code itself (?) -- I have never tried to do this. The I/O support it for the countries that reverse the symbols, but the compilers speak american, as far as I know.
a cin statement, eg
string dummy;
cin << dummy;
will prevent the console from closing