Student int i string n char g string d string m int c

Info icon This preview shows pages 2–6. Sign up to view the full content.

Student( int i, string n, char g, string d, string m, int c, double gp) { id=i; name=n; gender=g; dob=d; major=m; credits=c; gpa=gp; } void getData() { cout << id << " " << name << " " ; cout << gender << " " << dob << " " ; cout << major << " " << credits << " " ; cout << gpa << endl; }
Image of page 2

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

CIS-247C OOP/C++ H2 Solutions 3/18/2012 int getCredits() { return credits; } }; int main() { Student s1(6984, "John Trovota" , 'M' , "1/1/1980" , "CIS" , 64, 3.75); Student s2(2323, "Britney Speer" , 'F' , "5/23/1984" , "BIS" , 78, 2.98); Student s3(1452, "Kathy Johnson" , 'F' , "12/25/1982" , "CIS" , 30, 3.33); Student s4(4321, "Bill Newton" , 'M' , "7/8/1976" , "BIS" , 100, 3.95); cout << "Student objects - Before Sorting:\n\n" ; s1.getData(); s2.getData(); s3.getData(); s4.getData(); // starting the sorting process Student st; if (s1.getCredits() > s2.getCredits()) { st=s1; s1=s2; s2=st; }; if (s1.getCredits() > s3.getCredits()) { st=s1; s1=s3; s3=st; }; if (s1.getCredits() > s4.getCredits()) { st=s1; s1=s4; s4=st; }; if (s2.getCredits() > s3.getCredits()) { st=s2; s2=s3; s3=st; }; if (s2.getCredits() > s4.getCredits()) { st=s2; s2=s4; s4=st; }; if (s3.getCredits() > s4.getCredits()) { st=s3; s3=s4; s4=st; }; cout << "\nStudent objects - After Sorting:\n\n" ; s1.getData(); s2.getData(); s3.getData(); s4.getData(); return 0; } H22 Output:
Image of page 3
CIS-247C OOP/C++ H2 Solutions 3/18/2012 H23 Source Code: //************************************************************** **** // CIS247C, H23 // Creating Employee class to process employee data //************************************************************** **** #include <iostream> #include <string> #include <stdlib.h> #include <iomanip> usingnamespace std; //************************************************************** // The Employee class //************************************************************** class Employee { string firstName; string lastName; char gender; int dependents; double salary; public : Employee() //default constructor { firstName = "" ; lastName = "" ; gender = 'N' ; dependents = 0; salary = 50000; } // 5 argument-constructor
Image of page 4

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

CIS-247C OOP/C++
Image of page 5
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.
  • Fall '12
  • Unknown
  • H2 Solutions

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern