help with loop counter in homework
Feb 28, 2013 at 7:31pm UTC
Hi, I have homework from my programming class that is supposed to look like this :
http://tinypic.com/view.php?pic=366h2&s=6
But I can't seem to get a loop counter going with the date or the payment number. If someone can help me or give me advice that would be great. Here is my current code so far.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <string>
using namespace std;
int main ()
{
int ACCU; // Patient account number
int CONSM; // Consultation date month
int CONSD; // Consultation date day
int CONSY; // Consultation date year
char SLASH; // Unsed / in date
float FEE; // Treatment fee
float INIT; // Initial payment
float TOTAL; // Total balance due
int C; // Counter
int NPAY; // Numbered payments
int DPAY; // Payment due dates
float TPAY; // Total amount payed
float BAL; // Outstanding balance
/* Intro. & Instructions */
cout << "This program will ask you for your patient account number, consultation date,\n" ;
cout << "treament fee, and initial payment. The program will then calculate the number of\n" ;
cout << "payments needed, the payment due dates, the total amount payed on those dates,\n" ;
cout << "and finally the outstanding balance.he charges an initial payment followed\n" ;
cout << "by monthly payments until the contract amount has been fully payed for. These monthly\n" ;
cout << "payments will be due on the first of every month starting the month following the\n" ;
cout << "consultation date.\n" ;
system ("cls" ); // Clear the screen
/* Data Input Section */
cout << "PATIENT ACCOUNT NUMBER: " ;
cin >> ACCU;
if (ACCU <= 1000 || ACCU >= 9999)
{
cout << "Please enter a correct account value." ;
}
else
{
cout << "CONSULTATION DATE: " ;
}
cin >> CONSM;
cin >> SLASH;
cin >> CONSD;
cin >> SLASH;
cin >> CONSY;
if (CONSM < 1 || CONSM > 12) cout << "Please enter a valid date." ;
else if (CONSD < 1 || CONSD > 31) cout << "Please enter a valid date." ;
cout << "\nTREATMENT FEE: $ " ;
cin >> FEE;
cout << "INITIAL PAYMENT: $ " ;
cin >> INIT;
BAL = FEE - INIT;
cout << "BALANCE DUE: $ " << BAL;
cout << " " << endl;
cout << setw(10) << "PAYMENT" <<setw(10) << "DUE" << setw(10) << "PAYMENT" << setw(10) << "TOTAL" << setw(13) << "OUTSTANDING" << endl;
cout << setw(10) << "NUMBER" <<setw(10) << "DATE" << setw(10) << "AMOUNT" << setw(10) << "PAID" << setw(10) << "BALANCE" << endl; cout << endl ;
cout << endl;
cout << "enter amount" ;
int a = 1
; for (float i = BAL; i >= 0 ; i = i - C )
{cout << "enter amount" ; cin >> C; cout << setw(10) << a + 1 ; cout <<setw(10) << CONSD + 1 << SLASH << CONSM << SLASH << CONSY << setw(10) << C << setw(10) << "PAID" << setw(10) << i << endl;
}
system ("PAUSE" );
return 0;
}
Last edited on Feb 28, 2013 at 8:48pm UTC
Feb 28, 2013 at 8:48pm UTC
Okay I got it but now the only thing is getting TPAY to keep adding to itself with C repeatedly.
Topic archived. No new replies allowed.