H72-solution

# Next three points reference checking objects a2 new

This preview shows pages 3–5. Sign up to view the full content.

Next three points reference Checking objects a[2] = new Checking(1133, "Smith" , "Barney" , 500.00, 7.50); a[3] = new Checking(3355, "Gates" , "Bill" , 50.55, 7.50); a[4] = new Checking(5577, "Peterson" , "John" , 4567.88, 9.50); int i, j; // Use pointers to call getter function to display data cout << "All Account Information: \n\n" ; for (i=0; i<5; i++) a[i]->getData(); // Sort all accounts by account id Account *aa; for (i=0; i<4; i++) for (j=i+1; j<5; j++) if (a[i]->getID() > a[j]->getID()) { aa=a[i]; a[i]=a[j]; a[j]=aa; } cout << "\nAll Accounts - Sorted by Account ID:\n\n" ; for (i=0; i<5; i++) a[i]->getData(); // Sort all accounts by account balance for (i=0; i<4; i++) for (j=i+1; j<5; j++) if (a[i]->getBalance() > a[j]->getBalance()) { aa=a[i]; a[i]=a[j]; a[j]=aa; } cout << "\nAll Accounts - Sorted by Account Balance:\n\n" ; for (i=0; i<5; i++) a[i]->getData(); // process individual transactions cout << endl; a[0]->deposit(555.55); a[1]->withdraw(3500.25); a[2]->deposit(123.45); a[3]->withdraw(100.00); a[4]->deposit(899.90); // sort accounts by account balance for (i=0; i<4; i++) for (j=i+1; j<5; j++) if (a[i]->getBalance() > a[j]->getBalance()) { aa=a[i]; a[i]=a[j]; a[j]=aa; } // display account information

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
cout << "\nAll Accounts - Sorted by Account Balance:\n\n" ; for (i=0; i<5; i++) a[i]->getData(); return 0; }
CIS-247C Homework H72 solutions 4/11/2012 H72 – Output:
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern