I have got your site of interest and useful. Iam a student and besides learning programing in class, i take time to teach myself C++ from the internet. i have this exercise in which i got stuck and wish to solicit for help,
do you offer help on such?
if its possible, i should be greatful if you helped on this.
im combining classes and structures.
thanks.
#include
#include
#include
#include
#include
#include
#include
#include
#define max 500
// Header files
#include < windows.h >
typedef unsigned short bil;
#define SCR 3
#define Number 4
#define Credit 3
#define Subject 5
class Technology
{
public:
virtual void accept ()=0;
virtual void compute ()=0;
virtual void display ()=0;
};
class Civil: public Technology
{
protected:
struct Students
{
char name[30];
char RegNo[25];
char course[5][5];
};
struct Course
{
char code[5];
float CUnit[5];
float GPsum[4];
;
bil input(bil &x);// introducing a prototype bil
bil score[SCR][2];
bil Total[Number][20];
bil CUnit[Credit][2];
Course courses={ {"CE601",0.0}, // initialize subjects
{"CE602",0.0},
{"CE603",0.0},
{"CE604",0.0},
{"CE605",0.0}}
void accept()
{
cout<<"\tInput Number of Students in this class:\t";
input(Total);
cout<<"\tEnter Credit units for following courses:\t";
for(bil i=0; i>courses[i].CUnit;
GPsum+=courses[i].CUnit;
}
system("cls\0");
students= new Student[Total]; // allocation of memory here
for(i=0;i>students[i].names;
cout << "\nEnter the RegNo:\t";
cin >>students[i].RegNo;
for(bil k=0;k>students[i].score[k];
if((students[i].score[k]<0) ||(students[i].score[k]>100))
{
cout<<"\nInvalid Mark Entered!\nThe marks should range from 0 to 100\n";
}
} while((students[i].score[k]<0) ||(students[i].score[k]>100));
} // end of marks entry loop
}
if (students) delete [] students; // release any allocated memory
}
void compute ()
{
// sorting
for(int s=0;s=50) // subject passmark
strcpy(students[i].course[k],PASSED);
else strcpy(students[i].course[k],RETAKE);
} // end of subjects analysis
// computing GPA
for(k=0;k bestGPA)
{
bestGPA=students[i].GPA;
best=i;
}
}
}
void display ()
{
cout<=80) return 5.0;
else if(mark>=75) return 4.5;
else if(mark>=70) return 4.0;
else if(mark>=65) return 3.5;
else if(mark>=60) return 3.0;
else if(mark>=55) return 2.5;
else if(mark>=50) return 2.0;
else if(mark>=45) return 1.5;
else if(mark>=40) return 1.0;
else if(mark>=35) return 0.5;
else return 0.0;
}
int main ()
{
Technology *Fot;
int ret;
char ch;
do
{
cout<<"\n1.DEPARTMENT OF CIVIL ENGINEERING";
cout<<"\n2.DEPARTMENT OF ELECTRICAL ENGINEERING";
cout<<"\n3.DEPARTMENT OF MECHANICAL ENGINEERING";
cout<<"\n4.Exit";
cout<<"\n\nEnter your choice ::";
cin>>(ch);
switch (ch)
{
case '1':
Fot=new Civil;
Fot->accept();
Fot->compute();
Fot->display();
ret=1;
break;
case '2':
Fot=new Electrical;
Fot->accept();
Fot->compute();
Fot->display();
ret=1;
break;
case'3':
Fot=new Mechanical;
Fot->accept();
Fot->compute();
Fot->display();
ret=1;
break;
case '4':
ret=0;
break;
default:
cout<<"\nSorry Input is out of range, Try again";
ret=1;
break;
}
}while(ret);
return 0;
} bil input(bil &x)
{
for(;;)
{
char trash[max]={0};
cin>>x;
if(cin.fail())
{
cin.ignore();
cin.clear();
}
cin.getline(trash,max);
if(strlen(trash)!=0)
cerr<
post your code enclosed in the [ code ] [ /code ] tags so it is formatted:
see the spaces get preserved and post the section of code u need help on, not 19 pages of it.