Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Visual C++ and MFC Fundamentals Chapter 21: Tree and List Controls


int main()
{
double Numbers[] = { 12.55, 94.68, 8.18, 60.37, 104.502, 75.05 };
int Count = sizeof(Numbers) / sizeof(double);

double Total = Sum(Numbers, Count);
double Avg = Average(Numbers, Count);
double Low = Min(Numbers, Count);
double High = Max(Numbers, Count);

cout << "Characteristics of the list";
cout << "\nMinimum: " << Low;
cout << "\nMaximum: " << High;
cout << "\nTotal: " << Total;
cout << "\nAverage: " << Avg << endl;

return 0;
}


  1. Test the application:


Characteristics of the list
Minimum: 8.18
Maximum: 104.502
Total: 355.332
Average: 59.222
Press any key to continue


  1. Close it and retur to MSVC

  2. To test the library with a GUI application, display the New Project dialog box. In the
    Project Types list, make sure Visual C++ Projects is selected. In the Templates list,
    click MFC Application

  3. In the Name edit box, type BusMathTest2 and press Enter

  4. Set the Application Type as Dialog Based. Set the Dialog Title to Business
    Mathematics and remove the About Box check box. Click Finish

  5. In Windows Explorer or My Computer, one after the other, copy th BusMath.lib and
    bmcalc.h files from the BusMath project to the BusMathTest2 folder inside the main
    BusMathTest2 folder

  6. Delete the OK button and design the dialog box as follows:


Control ID Caption
Static Text Number &1:
Edit Control IDC_NUMBER1
Static Text Number &2:
Edit Control IDC_NUMBER2
Free download pdf