#include #include #include using namespace std; #include “afxwin.h” #include #include “Net.h” //void printdata(CStringList& lastnamelist, double number[6][6]); //void printtotals(double totalarrays[]); void printheading(); void printreport(Net* person[]); void printhighest(Net* person[]); void getsearch(Net* person[]); void getsort(Net* person[]); void processgroup(Net* person[]); void compute(Net* person[]); #pragma unmanaged int main() { system(“cls”); system(“Color 70”); CString Connection; CDatabase database; CString username; CString password; username = “DESKTOP-LG37VVR\SQLEXPRESS\jcswa”; Connection = _T(“Driver={SQL Server Native Client 11.0};Server=DESKTOP-LG37VVR\SQLEXPRESS;Database=MonthEndBalanceSQL;Trusted_Connection=Yes;Uid=”) + username + _T(“;Pwd=”) + password + _T(“;”); database.OpenEx(Connection, CDatabase::useCursorLib); const int size = 10; Net* person[size]; int i = 0; CString query = “SELECT LastName, PreviousBalance, Payments, Charges FROM MonthendTable”; CRecordset recordset(&database); CString temp, record; recordset.Open(CRecordset::forwardOnly, query, CRecordset::readOnly); CString lastname; CStringList lastnamelist; CString spreviousBalance, spayments, scharges, snewbalance, sfinancecharge, smonthendbalance; double previousBalance, payments, charges, newbalance, financecharge, monthendbalance; //double number[6][6]; int col = 0, row = 0; while (!recordset.IsEOF()) { record = _T(“”); register int len = recordset.GetODBCFieldCount(); recordset.GetFieldValue(“LastName”, lastname); recordset.GetFieldValue(“PreviousBalance”, spreviousBalance); recordset.GetFieldValue(“Payments”, spayments); recordset.GetFieldValue(“Charges”, scharges); //lastnamelist.AddHead(lastname); col = 0; previousBalance = atof(spreviousBalance); payments = atof(spayments); charges = atof(scharges); person[i++] = new Net(lastname, previousBalance, payments, charges); row = row + 1; recordset.MoveNext(); } processgroup(person); compute(person); printheading(); printreport(person); printhighest(person); getsort(person); getsearch(person); cout << endl << endl; cout << "Program end" << endl; cin.get(); while (cin.get() != 'n'); return 0; } void processgroup(Net* person[]) { int num = Net::getcount(); Net* temp = person[0]; for (int x = 0; x < num; x++) { temp->copydatatogroup(person[x]); } } void printheading() { cout << endl << endl; cout << setw(12) << "Last Name" << setw(18) << "Previous Balance" << setw(18) << "Payments" << setw(18) << "Charges" << setw(18) << "New Balance" << setw(18) << "Finance Charge" << setw(18) << "Month End Balance" << endl; cout << endl; } void compute(Net* person[]) { int col = 0; int num = Net::getcount(); Net* object = person[0]; for (int row = 0; row < num; row++) { object->compute(person[row], row, col); } person[0]->addcolumns(); } void printreport(Net* person[]) { Net* object = person[0]; person[0]->printdata(); } void printhighest(Net* person[]) { int num; num = Net::getcount(); Net* top = person[0]; for (int st = 1; st < num; st++) { if (*top > person[st]) top = top; else top = person[st]; } cout << "nPerson with the highest month end balance: " << endl; cout << top; } void getsearch(Net* person[]) { int num, index = 0; char name[20]; CString namsearch; cout << "nEnter the name to search "; cin >> name; namsearch = (CString)name; bool found = false; num = Net::getcount(); int x = 0; while ((found != true) && (x < num)) { if (*person[x] == namsearch) { cout << person[x]; found = true; } x++; } if (found == false) cout << "Object not found " << endl; } void getsort(Net* person[]) { Net* object = person[0]; object->sortdata(); }
Don't use plagiarized sources. Get Your Custom Essay on
[SOLVED] Rewriting a Program
Get a 15% discount on this Paper
Quality Guaranteed
With us, you are either satisfied 100% or you get your money back-No monkey business