Help with Event Controlled Loop.
I am just a student who have a programming class that is not related to my course.
So I am helping for your help guys.
This is the needed output:
Enter Amount Borrowed: 5000
Payment # 1: 1000
Current Balance: 4000
Payment # 2: 2000
Current Balance: 2000
Payment # 3: 1000
Current Balance: 1000
Payment # 4: 100
Current Balance: 900
Payment # 5: 500
Current Balance: 400
Payment # 6: 400
Current Balance: 0
YOU ARE PAID!
I try my best to answer this. When i insert the code below, its not adding the input value while loop. For example, The amount borrowed is 5000, i enter 1000. So the current balance is 4000, when i enter 500, it must be 3500, right ? but its still 4500 on the screen. So its not adding while loop. here's my code:
Code:
// HARD.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <conio.h>
using namespace std;
void main()
{
int num=0, //input value
ab, //Amount Borrowed
p=0, //payment number counter
cb=0; //Current Balance
float
sum=0; //add
cout<<"Enter Amount Borrowed:";
cin>>ab;
while(ab!=0)
{
sum+=num;
p=p+1;
cout<<"Payment#"<<p<<":";
cin>>num;
cb=ab-num;
cout<<"Current Balance:"<<cb<<endl;
}
cout<<"You are Paid";
getch();
}