Task:Make a program which can show the money left owed to the user while the user inputs the money owed total and the amount he can pay each month.
After each month, show the user how much he is left owed, he CANNOT repay more then the amount neccesary!
Example User owes total of 120$
1. month – 35$ (left owed 85$)
2. month – 50$ (left owed 35$)
3. month – 12$ (left owed 23$)
4. month – 23$ (left owed 0$)
I got this far but have no idea why my program just doesn't calculate the ''left owed'' and doesn't stop when the guy actually pays everything lol
#include <iostream.h>
#include <math.h>
#include <conio.h>
int main()
{
clrscr();
int x, y, sum=0;
cout<< "Input total amount owed ";
cin>> x;
do
{
cout <<"Input amount you can repay each month: ";
cin >>y;
if (x>y) sum=sum+y;
}
while (x=sum);
cout <<"\nMoney left owed: "<<sum;
getch();
}
#include <math.h>
#include <conio.h>
int main()
{
clrscr();
int x, y, sum=0;
cout<< "Input total amount owed ";
cin>> x;
do
{
cout <<"Input amount you can repay each month: ";
cin >>y;
if (x>y) sum=x-y;
cout <<"\nMoney left owed: "<<sum;
}
while (x>=sum);
getch();
}
your condition must be like this if(x>=y)you should put another variable their e.g int variable=0; and do this variable=x-sum; and then
change this cout<<"\nMoney left owed: "<<variable
and your while condition can should be this while(x>0);
#include <iostream.h>
#include <math.h>
#include <conio.h>
int main()
{
clrscr();
int x, y, sum=0, n=0;
cout<< "Input total amount owed ";
cin>> x;
do
{
cout <<"Input amount you can repay each month: ";
cin >>y;
if (x>=y) n=x-sum;
cout <<"\nMoney left owed: "<<n;
}
while (x>0);
getch();
}
#include <iostream.h>
#include <math.h>
#include <conio.h>
int main()
{
clrscr();
int x, y, sum=0, n=0;
cout<< "Input total amount owed ";
cin>> x;
do
{
cout <<"Input amount you can repay each month: ";
cin >>y;
if(x>=y)
{
sum=x-y;
n=x-sum;
cout<<"\nMoney left owed: "<<n;
}
}
while (x>0);
getch();
}