Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //header.h
- #include <iostream>
- #include <string>
- using namespace std;
- #include "stdafx.h"
- #using <mscorlib.dll>
- using namespace System;
- #pragma once
- #ifndef MEB_H
- #define MEB_H
- class Meb : public CObject
- {
- public:
- Meb( CString &, double = 0.0, double = 0.0, double = 0.0);
- friend ostream & operator<<(ostream&, const Meb *);
- int operator > ( Meb * p);
- static int getcount();
- static void printtotals();
- private:
- CString lastName;
- double financeCharge, previousBalance, payments, charges,newBalance, monthEndBalance;
- static double total_ monthEndBalance;
- static int count;
- void compute();
- };
- #endif
- // stdafx.h : include file for standard system include files,
- // or project specific include files that are used frequently, but
- // are changed infrequently
- //
- #if !defined(AFX_STDAFX_H__7A8C2116_A185_11D2_8FB5_A6CEBACABB62__INCLUDED_)
- #define AFX_STDAFX_H__7A8C2116_A185_11D2_8FB5_A6CEBACABB62__INCLUDED_
- #if _MSC_VER > 1000
- #pragma once
- #endif // _MSC_VER > 1000
- #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
- #include <afxwin.h> // MFC core and standard components
- #include <afxext.h> // MFC extensions
- #include <afxdisp.h> // MFC Automation classes
- #include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
- #ifndef _AFX_NO_AFXCMN_SUPPORT
- #include <afxcmn.h> // MFC support for Windows Common Controls
- #endif // _AFX_NO_AFXCMN_SUPPORT
- //{{AFX_INSERT_LOCATION}}
- // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
- #endif // !defined(AFX_STDAFX_H__7A8C2116_A185_11D2_8FB5_A6CEBACABB62__INCLUDED_)
- //source.cpp
- #include <iostream>
- #include <iomanip>
- #include <string>
- #include "Header1.h"
- using namespace std;
- int Meb::count=0;
- double Meb::total_ monthEndBalance=0;
- Meb::Meb(CString & sname, double pb, double ps, double cs {
- lastName=sName;
- previousBalance= pb;
- payments=ps;
- charges= cs;
- compute();
- }
- void Meb::compute() {
- newBalance= payments + charges;
- financeCharge= newBalance * .12;
- monthEndBalance= newBalance + financeCharge;
- count++;
- totalMonthEndBalance+= monthEndBalance;
- }
- ostream &operator<<(ostream & cout, const Meb *p) {
- cout<<setw(10)<<p-> lastName<<setw(10)<<p-> previousBalance <<setw(10)<<p-> payments<<setw(10)<<p->charges<<setw(10)<<p->newBalance<<setw(10)<<p-> financeCharge<<setw(10)<<p-> monthEndBalance<<endl;
- return cout;
- }
- void Meb::printtotals() {
- cout<<endl;
- cout<<"Total Month End balance "<<total_ monthEndBalance<<endl;
- cout<<"Number of objects created "<<count<<endl;
- }
- int Meb::getcount() {
- return count;
- }
- int Meb::operator > (Meb * p)
- {
- if (this->monthEndBalance > p-> monthEndBalance)
- return 1;
- else
- return 0;
- }
- //source1.cpp
- #include <iostream>
- #include <iomanip>
- using namespace std;
- #include "afxwin.h"
- #include <afxdb.h>
- #include "Header.h"
- void printheading();
- void printreport(Meb*person[]);
- void printhighest(Meb*person[]);
- int main() {
- system("cls");
- CString Connection;
- CDatabase database;
- CString username;
- CString password;
- username = "STUDENTS\\bkelly18";
- Connection =_T("Driver={SQL Server Native Client 11.0};Server=VD-LAB-CLA-111SQLEXPRESS;AttachDbFilename=F:\\Database1\\DataBases\\MonthEndBalance\\MonthEndBalanceSQL.mdf;Trusted_Connection=Yes;Uid=")+username+_T(";Pwd=")+password+_T(";");
- database.OpenEx(Connection,CDatabase::useCursorLib);
- const int size=10;
- Meb*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, s previousBalance, sPayments, scharges;
- double previousBalance, payments, charges, newBalance, financeCharge, monthEndBalance;
- while(!recordset.IsEOF()) {
- record=_T("");
- register int len=recordset.GetODBCFieldCount();
- recordset.GetFieldValue("Lastname", lastName);
- recordset.GetFieldValue("PreviousBalance", sPayments);
- recordset.GetFieldValue("Charges", scharges);
- previousBalance= atof(s previousBalance);
- payments= atof (sPayments);
- person[i++]= new Meb( lastName, previousBalance, payments, charges);
- recordset.MoveNext();
- }
- printheading();
- printreport(person);
- printhighest(person);
- cout<<endl<<endl;
- return 0;
- }
- void printheading() {
- cout<<endl<<endl;
- cout<<setw(40)<<"Month End Balance Report"<<endl;
- cout<<setw(15)<<" lastName"<<setw(15)<<" previousBalance"<<setw(15)
- <<"payments"<<setw(15)<<"charges"<<setw(15)<<"financeCharge"<<setw(15)<<
- "newBalance"<<setw(15)<<"month_end_balce"<<setw(15)<<endl<<endl;
- }
- void printreport(Meb*person[]) {
- int num = Meb::getcount();
- for (int i = 0; i < num; i++) {
- cout<<person[st];
- }
- Meb::printtotals();
- }
- void printhighest( Meb * person[]) {
- int num;
- num = Meb::getcount();
- Meb*top = person[0];
- for (int i = 1; i < num; i++) {
- if (*person[st]>top )
- top = person[st];
- }
- cout << "\nThe person with the highest pieces:” << top;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement