Advertisement
okelikai

Untitled

Mar 28th, 2019
485
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.74 KB | None | 0 0
  1.   //header.h
  2. #include <iostream>
  3. #include <string>
  4. using namespace std;
  5. #include "stdafx.h"
  6. #using <mscorlib.dll>
  7. using namespace System;
  8.  
  9. #pragma once
  10.  
  11. #ifndef MEB_H  
  12. #define MEB_H
  13.  
  14. class Meb : public CObject
  15. {
  16. public:
  17.      Meb( CString &, double = 0.0, double = 0.0, double = 0.0);  
  18.      friend ostream & operator<<(ostream&, const Meb *);
  19.      int  operator > ( Meb * p);
  20.      static int getcount();
  21.      static void printtotals();
  22. private:
  23.       CString  lastName;
  24.       double financeCharge,  previousBalance, payments, charges,newBalance,                      monthEndBalance;
  25.       static double total_ monthEndBalance;
  26.       static int count;
  27.       void compute();
  28.  
  29. };
  30. #endif
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40. // stdafx.h : include file for standard system include files,
  41. //  or project specific include files that are used frequently, but
  42. //      are changed infrequently
  43. //
  44.  
  45. #if !defined(AFX_STDAFX_H__7A8C2116_A185_11D2_8FB5_A6CEBACABB62__INCLUDED_)
  46. #define AFX_STDAFX_H__7A8C2116_A185_11D2_8FB5_A6CEBACABB62__INCLUDED_
  47.  
  48. #if _MSC_VER > 1000
  49. #pragma once
  50. #endif // _MSC_VER > 1000
  51.  
  52. #define VC_EXTRALEAN        // Exclude rarely-used stuff from Windows headers
  53.  
  54. #include <afxwin.h>         // MFC core and standard components
  55. #include <afxext.h>         // MFC extensions
  56. #include <afxdisp.h>        // MFC Automation classes
  57. #include <afxdtctl.h>        // MFC support for Internet Explorer 4 Common Controls
  58. #ifndef _AFX_NO_AFXCMN_SUPPORT
  59. #include <afxcmn.h>            // MFC support for Windows Common Controls
  60. #endif // _AFX_NO_AFXCMN_SUPPORT
  61.  
  62.  
  63. //{{AFX_INSERT_LOCATION}}
  64. // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  65.  
  66. #endif // !defined(AFX_STDAFX_H__7A8C2116_A185_11D2_8FB5_A6CEBACABB62__INCLUDED_)
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74. //source.cpp
  75. #include <iostream>
  76. #include <iomanip>
  77. #include <string>
  78. #include "Header1.h"
  79. using namespace std;
  80.  
  81. int Meb::count=0;
  82. double Meb::total_ monthEndBalance=0;
  83.  
  84. Meb::Meb(CString &  sname, double pb, double ps, double cs {
  85.    lastName=sName;
  86.    previousBalance= pb;
  87.    payments=ps;
  88.    charges= cs;
  89.    compute();
  90. }
  91.  
  92. void Meb::compute() {
  93.     newBalance= payments + charges;
  94.     financeCharge= newBalance * .12;
  95.     monthEndBalance= newBalance + financeCharge;
  96.     count++;
  97.     totalMonthEndBalance+= monthEndBalance;
  98. }
  99.  
  100. ostream &operator<<(ostream & cout, const Meb *p) {    
  101.  
  102. 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;  
  103.  
  104.      return cout;
  105. }
  106.  
  107.  
  108. void Meb::printtotals() {
  109.   cout<<endl;
  110.   cout<<"Total Month End balance "<<total_ monthEndBalance<<endl;
  111.   cout<<"Number of objects created "<<count<<endl;
  112.  
  113. }
  114.  
  115. int Meb::getcount() {    
  116.   return count;
  117. }
  118.  
  119. int Meb::operator > (Meb  * p)
  120.  
  121. {
  122.     if (this->monthEndBalance > p-> monthEndBalance)
  123.     return 1;
  124.       else
  125.          return 0;
  126. }
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144. //source1.cpp
  145. #include <iostream>
  146. #include <iomanip>
  147. using namespace std;
  148.  
  149. #include "afxwin.h"
  150. #include <afxdb.h>
  151.  
  152. #include "Header.h"
  153.  
  154. void printheading();
  155. void printreport(Meb*person[]);
  156. void printhighest(Meb*person[]);
  157.  
  158.  
  159. int main() {      
  160.     system("cls");
  161.  
  162.          CString Connection;
  163.     CDatabase database;
  164.  
  165.     CString username;
  166.             CString password;
  167.             username = "STUDENTS\\bkelly18";
  168.    
  169. 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(";");
  170.  
  171.        database.OpenEx(Connection,CDatabase::useCursorLib);
  172.  
  173.     const int size=10;
  174.    
  175.        Meb*person[size];
  176.      
  177.       int i=0;
  178.    
  179.        CString query ="SELECT Lastname, PreviousBalance, Payments, Charges FROM MonthEndTable";
  180.  
  181.     CRecordset recordset(&database);
  182.     CString temp,record;
  183.     recordset.Open(CRecordset::forwardOnly,query,CRecordset::readOnly);
  184.  
  185.     CString  lastName, s previousBalance, sPayments, scharges;
  186.  
  187.     double  previousBalance, payments, charges, newBalance, financeCharge,    monthEndBalance;
  188.    
  189.     while(!recordset.IsEOF()) {
  190.            record=_T("");
  191.            register int len=recordset.GetODBCFieldCount();
  192.            recordset.GetFieldValue("Lastname",  lastName);
  193.                   recordset.GetFieldValue("PreviousBalance", sPayments);
  194.                   recordset.GetFieldValue("Charges", scharges);
  195.              previousBalance= atof(s previousBalance);
  196.                      payments= atof (sPayments);
  197.                 person[i++]= new Meb( lastName,  previousBalance, payments, charges);
  198.            recordset.MoveNext();          
  199.       }
  200.      
  201.           printheading();
  202.           printreport(person);
  203.           printhighest(person);
  204.           cout<<endl<<endl;
  205.        
  206.     return 0;
  207.  
  208. }
  209. void printheading() {
  210.      cout<<endl<<endl;
  211.      cout<<setw(40)<<"Month End Balance Report"<<endl;
  212.      cout<<setw(15)<<" lastName"<<setw(15)<<" previousBalance"<<setw(15)
  213.          <<"payments"<<setw(15)<<"charges"<<setw(15)<<"financeCharge"<<setw(15)<<
  214.          "newBalance"<<setw(15)<<"month_end_balce"<<setw(15)<<endl<<endl;
  215. }
  216.  
  217. void printreport(Meb*person[]) {
  218.         int num = Meb::getcount();
  219.        
  220.         for (int i = 0; i < num; i++) {
  221.         cout<<person[st];
  222.         }
  223.  
  224.        Meb::printtotals();
  225. }
  226.  
  227. void printhighest( Meb * person[])  {
  228.     int num;
  229.  
  230.       num = Meb::getcount();
  231.       Meb*top = person[0];
  232.        
  233.        for (int i = 1; i < num; i++) {
  234.          if (*person[st]>top )
  235.             top = person[st];
  236.       }
  237.  
  238.       cout << "\nThe person with the highest pieces:” << top;
  239. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement