Oct 11, 2011 at 9:48pm UTC
I am having some trouble with a loop program if anyone could give me some pointers i would be greatly appreciative thanks.
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
double pnumber, month, day, year, treatmentfee, initialpymnt, balance, pymnt,
pymntnum, totalpayed, outbalance;
cout << "Enter patient account number ";
cin >> pnumber;
cout << "Enter consultation date month ";
cin >> month;
cout << "Enter consultation date day ";
cin >> day;
cout << "Enter consultation date year ";
cin >> year;
cout << "Enter patients treatment fee ";
cin >> treatmentfee;
cout << "Enter patients initial payment ";
cin >> initialpymnt;
cout << "Enter patients monthly payment ";
cin >> pymnt;
totalpayed = initialpymnt;
pymntnum = 1;
balance = treatmentfee - initialpymnt;
outbalance = treatmentfee - initialpymnt - pymnt;
totalpayed = initialpymnt + pymnt;
while (outbalance < treatmentfee)
{
cout << "Enter patients monthly payment ";
cin >> pymnt;
pymntnum = pymntnum + 1;
month = month + 1;
if (month > 12)
month = 01;
}
cout << "Patient account number: " << pnumber << endl;
cout << "Consultation date: " << month << "/" << day << "/" << year << endl << endl;
cout << "Treatment fee: " << treatmentfee << endl;
cout << "Initial payment: " << initialpymnt << endl;
cout << "Balance due: " << balance << endl;
cout << "Payment Due Payment Total Outstanding \n";
cout << "Number Date Amount Paid Balance \n";
cout << pymntnum << setw(5) << month << day << year << setw(5) << pymnt << setw(5) << totalpayed << setw(5) << outbalance << endl;
return 0;
}
Oct 11, 2011 at 10:18pm UTC
sorry not trying to be rude my problem is i need to have this program loop until a "balance" is met i.e. a patients hospital bill.
Oct 11, 2011 at 10:23pm UTC
And your program isn't doing that? Then what is it doing instead?
Oct 11, 2011 at 10:29pm UTC
+1 Athar
It's hard to solve a problem when you don't tell us what the problem is.
Oct 11, 2011 at 10:44pm UTC
it allows me to keep entering the pymnt number and never totals
Oct 11, 2011 at 11:16pm UTC
You neither change outbalance nor treatmentfee inside the loop, so the loop condition can't ever become false.
Last edited on Oct 11, 2011 at 11:17pm UTC
Oct 12, 2011 at 12:50am UTC
ok thanks now i just have to figure out the proper way to word that hmm should be fun though i dont know how to do it correctly off the top of my head here goes nothing