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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
|
#include <iostream>
#include <iomanip>
#include <cstdlib>
using namespace std;
#define STUDENT "Aaron Lewis"
int main()
{
int ACC_NUMBER, //Patient Number.
DAY, //Day of the month of treatment.
MONTH, //Month of treatment.
YEAR, //Year of treatment.
PAYMNT_NUM;//Payment number counter.
float TREAT_FEE, // Treatment fee amount.
INIT_PAYMENT, //Initial payment amount.
BALANCE, //Balance due amount.
MON_PAYMENT, //chosen Amount of the monthly payment.
TOTAL_PAID; //total amount payed to date.
/********************
* Data Input Section*
********************/
system("cls");
cout << "Please enter the patient's 4 digit account number: "; // User input for patient account number. Check to see if it's not over 4 digits, or a negative number.
cin >> ACC_NUMBER;
while (ACC_NUMBER>9999 || ACC_NUMBER<0)
{
cout << "\n";
cout << "incorrect account number. Account numbers are 4 numerical digits above 0.\n";
cout << "Please enter a correct account number: ";
cin >> ACC_NUMBER;
}
//----------------------------------------------------------
cout << "What month was the treatment? (EX: \"02\" for february): "; // User input for treatment month. Check to see if it's not over 12 or less than 0.
cin >> MONTH;
while (MONTH>12 || MONTH<0)
{
cout << "\n";
cout << "incorrect month number. Please enter a month from 1 to 12: ";
cin >> MONTH;
}
//----------------------------------------------------------
cout << "What day of the month was the treatment? (EX: \"25\" for the 25th): "; // User input for treatment month. Check to see if it's not over 12 or less than 0.
cin >> DAY;
while (DAY>31 || DAY<0)
{
cout << "\n";
cout << "incorrect day number. Please enter a day from 1 to 31: ";
cin >> DAY;
}
//----------------------------------------------------------
cout << "What was the year of the treatment? (EX: \"15\" for 2015): "; // User input for treatment year. Check to see if it's not less than 0.
cin >> YEAR;
while (YEAR<0)
{
cout << "\n";
cout << "incorrect year number. Please enter a year above 0: ";
cin >> YEAR;
}
//----------------------------------------------------------
cout << "Please enter the treatment fee in dollars:"; // User input for the cost of treatment. Check to see if it's not less than 0.
cin >> TREAT_FEE;
while (TREAT_FEE<0)
{
cout << "\n";
cout << "incorrect fee amount. Please enter an ammount greater than 0: ";
cin >> TREAT_FEE;
}
//----------------------------------------------------------
cout << "Please enter the amount of the initial payment:"; // User input for the initial payment amount. Check to see if it's not less than 0.
cin >> INIT_PAYMENT;
while (INIT_PAYMENT<0)
{
cout << "\n";
cout << "incorrect payment amount. Please enter an ammount greater than 0: ";
cin >> INIT_PAYMENT;
}
//----------------------------------------------------------
cout << "Please enter your monthly payment amount:"; // User input for the monthly payment amount. Check to see if it's not less than 0.
cin >> MON_PAYMENT;
while (MON_PAYMENT<0)
{
cout << "\n";
cout << "incorrect payment amount. Please enter an ammount greater than 0: ";
cin >> MON_PAYMENT;
}
//----------------------------------------------------------
cout << "Thank you. Here is your payment schedule information\n" << endl;
PAYMNT_NUM = 0; //initialize the payment number counter.
cout << setfill('*');
cout << setprecision(2) << fixed;
cout << left << setw(50) <<"TREATMENT FEE:" << "$" << TREAT_FEE << endl;
cout << left << setw(50) << "INITIAL PAYMENT:" << INIT_PAYMENT << endl;
cout << left << setw(50) <<"BALANCE DUE:" << TREAT_FEE - INIT_PAYMENT << endl;
cout << "\n";
cout << left << setw(15) << "PAYMENT" << setw(15) << "DUE" << setw(15) << "PAYMENT" << setw(15) << "TOTAL" << setw(15) << "OUTSTANDING" << endl;
cout << left << setw(15) << "NUMBER" << setw(15) << "DATE" << setw(15) << " AMOUNT" << setw(15) << " PAID" << setw(15) << " BALANCE" << endl;
cout << left <<"\n";
/*****************
* Initial values *
*****************/
BALANCE = TREAT_FEE - INIT_PAYMENT; //Balance is initialized as: the treatment fee minus the initial payment.
TOTAL_PAID = INIT_PAYMENT; //Total amount payed is initialized as: the initial payment.
DAY = 1; //Day of monthly payments initialized to the first day of the month.
MONTH + 1; //Month of payments initialized to the month after the original month of the consultation.
/************
* Main Loop *
************/
while (BALANCE>0)
{
PAYMNT_NUM += 1; //increase the payment number by 1.
if (BALANCE < MON_PAYMENT)
{
MON_PAYMENT = BALANCE; //If the remaining balance is lower than the chosen monthly payment, set the monthly payment to the remaining amount. (to avoid overpaying)
}
MONTH += 1; //Month increased by 1, as payments are due at the first of the month.
if (MONTH>12) //Once the month exceeds 12, increase the year by 1 and set the month back to 1.
{
YEAR += 1;
MONTH = 1;
}
BALANCE = BALANCE - MON_PAYMENT; //Subtracting the monthly payment from the remaining balance.
TOTAL_PAID = TOTAL_PAID + MON_PAYMENT; //Add monthly payment to the total amount paid.
cout << setw(15) << PAYMNT_NUM;
cout << MONTH << "/" << DAY << "/" << YEAR << setw(15) << " " << MON_PAYMENT << setw(15) << " " << TOTAL_PAID << setw(15) << BALANCE << "\n";
}
cout << "\n";
cout << setfill('*') << setw(10) << right << "* " << "PAYMENT SCHEDULE PRINTED BY: " << STUDENT << setw(10) << left << " *" << endl;
return 0;
}
|