The following code works. However i want it so when the user reaches 500 dollars the last cout statement will run. But for some reason i can't get it to work properly. It skips the last cout statment and enters -numbers.
#include <iostream>
using namespace std;
int main ()
{
int money = 500;
int moneyspent;
do
{
cout<<"Please enter how much money you would like to spend"<<endl;
cin >> moneyspent;
if(moneyspent < 500)
money = money - moneyspent;
cout<<"You have "<<money<<" dollars left to spend"<<endl;
}
while(moneyspent != 500);
cout <<"You are out of cash jarboni"<<endl;
return 0;
}