program solved
Mar 10, 2014 at 6:41pm UTC
I posted this about a month ago asking for help but it was taken down like a couple of days ago. I wanted to put it back up for anyone that needed help or wanted to see a program for structs.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
#include<iomanip>
#include <iostream>
#include <string>
using namespace std;
class Student
{
private :
int identification;
double Grading;
string FirstName, LastName;
public :
int getidentification ()
{
return identification;
}
void setidentification (int number)
{
identification = number;
}
double getGrading ()
{
return Grading;
}
void setGrading(double number)
{
Grading = number;
}
string getFirstName ()
{
return FirstName;
}
void setFirstName (string name)
{
FirstName = name;
}
string getLastName ()
{
return LastName;
}
void setLastName (string name)
{
LastName = name;
}
};
void sort (Student studentone, Student studentTwo, Student studentThree)
{
Student first, second, third;
if (studentone.getGrading() > studentTwo.getGrading())
{
if (studentone.getGrading() > studentThree.getGrading())
{
first = studentone;
if (studentTwo.getGrading() > studentThree.getGrading())
{
second = studentTwo;
third = studentThree;
}
else
{
second = studentThree;
third = studentTwo;
}
}
else
{
first = studentThree;
if (studentone.getGrading() > studentTwo.getGrading())
{
second = studentone;
third = studentTwo;
}
else
{
second = studentTwo;
third = studentone;
}
}
}
else
{
if (studentTwo.getGrading() > studentThree.getGrading())
{
first = studentTwo;
if (studentone.getGrading() > studentThree.getGrading())
{
second = studentone;
third = studentThree;
}
else
{
second = studentThree;
third = studentone;
}
}
else
{
first = studentThree;
if (studentone.getGrading() > studentTwo.getGrading())
{
second = studentone;
third = studentTwo;
}
else
{
second = studentTwo;
third = studentone;
}
}
}
cout << setfill('0' ) << setw(3) << first.getidentification() << " " ;
cout << setprecision(5) << first.getGPA() << " " << first.getFirstName() << endl;
cout << setfill('0' ) << setw(3) << second.getidentification() << " " ;
cout << setprecision(5) << second.getGPA() << " " << second.getFirstName() << endl;
cout << setfill('0' ) << setw(3) << third.getidentification() << " " ;
cout << setprecision(5) << third.getGPA() << " " << third.getFirstName() << endl;
}
int main ()
{
Student ChrisBosh, DwyaneWade, LeBronJames;
LeBronJames.setFirstName("LeBron" );
LeBronJames.setLastName("James" );
LeBronJames.setidentification(0006);
LeBronJames.setGrading(3.0);
ChrisBosh.setFirstName("Chris" );
ChrisBosh.setLastName("Bosh" );
ChrisBosh.setidentification(0001);
ChrisBosh.setGrading(2.0);
DwyaneWade.setFirstName("Dwyane" );
DwyaneWade.setLastName("Wade" );
DwyaneWade.setidentification(0003);
DwyaneWade.setGrading(4.0);
sort(DwyaneWade, ChrisBosh, LeBronJames);
system("pause" );
return 0;
Last edited on Mar 10, 2014 at 7:37pm UTC
Topic archived. No new replies allowed.