guide me on this code
Apr 6, 2016 at 7:33am UTC
i have the code below which calculates trimester grades. i want it to do for five trimester and each trimester a student should study for 15hrs and a total of 75hrs at the end of the five trimesters in order to graduate.Failure to me the above condition a student should not graduate. please guide me on how to go about it
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 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319
#include<iostream>
#include<string>
using namespace std;
void Student_Info();
void CourseMark();
float CourseGrade(float );
void Display_GradeRport();
void Culculate_CGPA();
void Status(float );
struct student
{
int ID,age,year,Trimester;
char fname[15];
char lname[15];
char sex;
float CGPA;
struct
{
float oop1;
float calculus1;
float economics;
float software;
float webdev1;
}course;
struct
{
float oop1g;
float calculus1g;
float economicsg;
float softwareg;
float webdev1g;
}grade;
};
struct student s[5];
int n;
int main()
{
cout<<"====================================================\n" ;
cout<<"Student Grade Report system.Using C++\n" ;
cout<<"Programmed by: group1\n\n" ;
cout<<"BSCIT (CSE)\n" ;
cout<<"OOP\n\n" ;
cout<<"Welcome To Student Grade Report:\n" ;
cout<<"====================================================\n" ;
Student_Info();
CourseMark();
Culculate_CGPA();
Display_GradeRport();
}
void Student_Info()
{
int i;
cout<<"Enter number of students:" ;
cin>>n;
cout<<"\nStudent Information:\n" ;
for (i=0;i<n;i++)
{
cout<<"Enter student_" <<i+1<<" First name:\n" ;
cin>>s[i].fname;
cout<<"Enter student_" <<i+1<<" Last name:\n" ;
cin>>s[i].lname;
cout<<"Enter student_" <<i+1<<" ID number:\n" ;
cin>>s[i].ID;
cout<<"Enter student_" <<i+1<<" Sex:\n" ;
cin>>s[i].sex;
cout<<"Enter student_" <<i+1<<" Age:\n" ;
cin>>s[i].age;
cout<<"Enter student_" <<i+1<<" Year:\n" ;
cin>>s[i].year;
cout<<"Enter student_" <<i+1<<" Trimester:\n" ;
cin>>s[i].Trimester;
}
}
void CourseMark()
{
int mark;
cout<<"Enter Students mark to corresponding course:\n" ;
for (int i=0;i<n;i++)
{
cout<<"Enter student_" <<i+1<<" oop1:\n" ;
cin>>s[i].course.oop1;
cout<<"Enter student_" <<i+1<<" calculus1:\n" ;
cin>>s[i].course.calculus1;
cout<<"Enter student_" <<i+1<<" economics:\n" ;
cin>>s[i].course.economics;
cout<<"Enter student_" <<i+1<<" software:\n" ;
cin>>s[i].course.software;
cout<<"Enter student_" <<i+1<<" webdev1:\n" ;
cin>>s[i].course.webdev1;
}
}
float CourseGrade(float mark)
{
float result;
if (mark<=100 && mark>90)
{
result=4.0;
cout<<"A+\n" ;
}
else if (mark<=90 && mark>85)
{
result=4;
cout<<"A\n" ;
}
else if (mark<=85 && mark>80)
{
result=3.75;
cout<<"A-\n" ;
}
else if (mark<=80 && mark>75)
{
result=3.5;
cout<<"B+\n" ;
}
else if (mark<=75 && mark>70)
{
result=3;
cout<<"B\n" ;
}
else if (mark<=70 && mark>65)
{
result=2.75;
cout<<"B-\n" ;
}
else if (mark<=65 && mark>60)
{
result=2.5;
cout<<"C+\n" ;
}
else if (mark<=60 && mark>50)
{
result=2;
cout<<"C\n" ;
}
else if (mark<=50 && mark>45)
{
result=1.75;
cout<<"C-\n" ;
}
else if (mark<=45 && mark>40)
{
result=1.5;
cout<<"D+\n" ;
}
else if (mark<=40 && mark>30)
{
result=1;
cout<<"D\n" ;
}
else if (mark<=30 && mark>0)
{
result=0;
cout<<"F\n" ;
}
else
{
cout<<"mark out of range.\n" ;
}
return result;
}
void Culculate_CGPA()
{
int credit=5;//credit hour of each course
int Tcredit=20;//total credit hour
int a;
float SumofGP[2]={0};
for (a=0;a<n;a++)
{
if ((s[a].grade.oop1g !=0 && s[a].grade.calculus1g !=0) && (s[a].grade.softwareg !=0 && s[a].grade.economicsg !=0 &&(s[a].grade.webdev1g!=0)))
{
SumofGP[a]=(s[a].grade.oop1g * credit)+ (s[a].grade.calculus1g * credit)+ (s[a].grade.softwareg * credit)+ (s[a].grade.economicsg*credit) + (s[a].grade.webdev1g*credit);
}
else if (s[a].grade.oop1g ==0)
{
SumofGP[a]= (s[a].grade.calculus1g * credit) + (s[a].grade.softwareg * credit) + (s[a].grade.economicsg*credit) +(s[a].grade.webdev1g *credit);
}
else if (s[a].grade.calculus1g ==0)
{
SumofGP[a]=(s[a].grade.oop1g * credit) + (s[a].grade.softwareg * credit) + (s[a].grade.economicsg*credit) + (s[a].grade.webdev1g*credit);
}
else if (s[a].grade.economicsg ==0)
{
SumofGP[a]=(s[a].grade.oop1g * credit) + (s[a].grade.calculus1g * credit) + (s[a].grade.softwareg * credit) + (s[a].grade.webdev1g*credit);
}
else if (s[a].grade.softwareg ==0)
{
SumofGP[a]=(s[a].grade.oop1g * credit) + (s[a].grade.calculus1g * credit) + (s[a].grade.webdev1g*credit) +
(s[a].grade.economicsg*credit);
}
else {
SumofGP[a]=(s[a].grade.oop1g * credit) + (s[a].grade.calculus1g * credit) + (s[a].grade.softwareg*credit) +
(s[a].grade.economicsg*credit);
}
s[a].CGPA=SumofGP[a]/Tcredit;
}
}
void Display_GradeRport()
{
int i,j;
float alpha;
cout<<"Student Grade Report:\n" ;
cout<<"================================================================\n" ;
for (i=0;i<n;i++)
{
cout<<"Full Name: " <<s[i].fname<<"\t" <<s[i].lname<<"\t" <<"Year:" <<s[i].year<<"\tTrimester: " <<s[i].Trimester<<endl;
cout<<"Sex: " <<s[i].sex<<"\t" <<"Age: " <<s[i].age<<endl<<endl;
for (j=0;j<4;j++)
{
if (j==0)
{
alpha=s[i].grade.oop1g;
cout<<"oop1: \t" ;
s[i].grade.oop1g=CourseGrade(s[i].course.oop1);
}
else if (j==1)
{
alpha=s[i].grade.calculus1g;
cout<<"calculus1: \t" ;
s[i].grade.calculus1g=CourseGrade(s[i].course.calculus1);
}
else if (j==2)
{
alpha=s[i].grade.economicsg;
cout<<"economics: \t" ;
s[i].grade.economicsg=CourseGrade(s[i].course.economics);
}
else
{
alpha=s[i].grade.softwareg;
cout<<"Communicative English:\t" ;
s[i].grade.softwareg=CourseGrade(s[i].course.software);
}
}
Culculate_CGPA();
cout<<"CGPA=" <<s[i].CGPA<<endl;;
Status(s[i].CGPA);
cout<<"==============================================================\n" ;
}
}
void Status(float sta)
{
if (sta==4)
{
cout<<"Status: Very great distinction.\n" ;
}
else if (sta>=3.75 && sta<=3.99)
{
cout<<"Status: Grate distinction.\n" ;
}
else if (sta>3.5 && sta<=3.74)
{
cout<<"Status: Distinction.\n" ;
}
else if (sta>3.49 && sta<=3.25)
{
cout<<"Status: dean's list.\n" ;
}
else if (sta>=2.0 && sta<=3.24)
{
cout<<"Status: Promoted.\n" ;
}
else if (sta>1.75 && sta<=1.99)
{
cout<<"Status: Warning.\n" ;
}
else if (sta>1.00 && sta<=1.74)
{
cout<<"Status: Readmission.\n" ;
}
else if (sta>0.0 && sta<1.0)
{
cout<<"Status: Distinction.\n" ;
}
}
Topic archived. No new replies allowed.