plz guide me soon so that i submit my assignment on saturday
huria 0 Newbie Poster
#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<string.h>
#include<process.h>
# include<fstream.h>
# include<stdlib.h>
#define NUM 4
class calculate
{
private:
int marks[5],cr_hr[5],tot_hr,i,gr_val[5],sum,result;
char grade[5];
float gpa;
public:
calculate()
{
char *subject[]={"oops","stats","culture","math","physics"};
tot_hr=0;
i=0;
sum=0;
}// end of calculte ()
/*===============getdata()================*/
void getdata(void)
{
char *subject[]={"oops","stats","culture","math","physics"};
/*=============marks loop============*/
for( i=0; i<5; i++)
{
cout<<"enter marks for "<<subject[i]<<" :\t";
cin>>marks[i];
cout<<endl;
}//end of marks loop
/*============credit hrs loop=========*/
for( i=0; i<5; i++)
{
cout<<"enter credit hrs for "<<subject[i]<< ":\t";
cin>>cr_hr[i];
cout<<endl;
}//end of credit hrs loop
}//end of getcode()
/*===============grades()===============*/
grades()
{
for(i=0; i<5; i++)
{
if( marks[i]>=80 && marks[i]<=100 )
grade[i]='A';
if( marks[i]>=60 && marks[i]<80 )
grade[i]='B';
if( marks[i]>=40 && marks[i]<60 )
grade[i]='C';
if( marks[i]<40 )
grade[i]='D';
if( marks[i]<30 )
grade[i]='f';
}//end of for
/*===========assign grade values=======*/
for(i=0; i<5; i++)
{
if( grade[i]=='A' )
gr_val[i]= 4;
if( grade[i]=='B' )
gr_val[i]= 3;
if( grade[i]=='C' )
gr_val[i]= 2;
if( grade[i]=='D' )
gr_val[i]= 1;
if( grade[i]=='f' )
gr_val[i]= 0;
}//end of grades value loop
/*============gpa===============*/
for(i=0; i<5; i++)
{
tot_hr += cr_hr[i];
result= cr_hr[i] * gr_val[i];
sum+= result;
}
gpa= float(sum) / tot_hr;
}//end of grades()
/*==================Save()==============*/
void save()
{
char *subject[]={"oops","stats","culture","math","physics"};
ofstream outfile("miniproject1.txt");
outfile<<"subjects\tcredit hrs\tmarks\t\tgrades"<<endl<<"\n";
for(int i=0; i<5; i++)
{
cout<<subject[i]<<"\t\t"<<cr_hr[i]<<"\t\t";
cout<<marks[i]<<"\t\t"<<grade[i]<<endl;
}//end of for
outfile<<"\nGPA : "<<gpa;
gotoxy(5,5);
settextstyle(TRIPLEX_FONT, HORIZ_DIR, 6);
cout<<"You 'Ve Successfully Created Miniproject1.txt";
}//end of save()
/*=======================quit()======================*/
quit()
{
char choice;
cout<<"Do u want to quit (y/n): ";
cin>>choice;
if(choice=='y')
exit(0);
} //end of quit()
/*================display()==============*/
display()
{
char *subject[]={"oops","stats","culture","math","physics"};
cout<<"subjects\tcredit hrs\tmarks\t\tgrades"<<endl<<"\n";
for(int i=0; i<5; i++)
{
cout<<subject[i]<<"\t\t"<<cr_hr[i]<<"\t\t";
cout<<marks[i]<<"\t\t"<<grade[i]<<endl;
}//end of for
gotoxy(10,40);
cout<<"Gpa ="<<gpa;
}//end of display()
};
/*=====================start of gui class===============================*/
class gui
{
private:
int driver,mode,LEFT,TOP,RIGHT,BOTTOM,DEPTH,TOPFLAG,EGA_BLUE;
int TRUE,count[4],left,right;
public:
gui()
{
char *options[NUM]={ "Enter Data",
"Display Data",
"Save",
"Quit" };
LEFT=3; TOP=3; RIGHT=635; BOTTOM=185; DEPTH=0; TOPFLAG=0;
EGA_BLUE=1; driver=EGA; mode=EGALO;
TRUE=1;
left=12; right=115;
}//end of gui()
graphic()
{
initgraph(&driver,&mode,"c:\\tc\\bgi");
setfillstyle(CLOSE_DOT_FILL,EGA_BLUE);
bar3d(LEFT,TOP,RIGHT,BOTTOM,DEPTH,TOPFLAG);
}//initializing graphics()
/*==================menu_scr()=======================*/
void menu_scr(int c, int t, int b)
{
int x=3,y=3;
char *options[NUM]={ "Enter Data",
"Display Data",
"Save",
"Quit" };
setfillstyle(SLASH_FILL,EGA_BLUE);
if(c==1)
bar3d(left,t,right,b,0,0);
if(c==2)
bar3d(left,t+25,right,b+25,0,0);
if(c==3)
bar3d(left,t+50,right,b+50,0,0);
if( c==4)
bar3d(left,t+75,right,b+75,0,0);
for(int i=0;i<4;i++)
{
gotoxy(x,y);
cout<<options[i];
y=y+3;
}
}//end of menu_scr()
/*===================getcode()================================*/
getcode(int c)
{
calculate c1;
char key;
int t=10,b=25,num;
key=getch();
if(key==0)
key=getch();
switch(key)
{
case 80: //down arrow key
if(c==1)
num=2;
else if(c==2)
num=3;
else if(c==3)
num=4;
else if(c==4)
num=1;
break;
case 72: //up arrow key
if(c==4)
num=3;
else if(c==3)
num=2;
else if(c==2)
num=1;
else if(c==1)
num=4;
break;
case 13: //if enter key is pressed
if (c==1)
{
num=2;
graphic();
gotoxy(4,4);
c1.getdata();
}
if(c==2)
{
num=3;
graphic();
gotoxy(4,4);
c1.grades();
c1.display();
}
if(c==3)
{
num=4;
graphic();
gotoxy(4,4);
c1.save();
}
if(c==4)
{
num=1;
graphic();
gotoxy(4,4);
c1.quit();
}
break;
/* case '0':
exit(0); */
}//end of switch
cleardevice();
graphic();
menu_scr(num,t,b);
return num;
}//end of getcode()
};//end of gui class
void main(void)
{
gui g1;
calculate c1;
int c=1,t=10,b=25,temp;
int TRUE=1;
g1.graphic();
g1.menu_scr(c,t,b);
while(TRUE)
{
temp= g1.getcode(c);
c=temp;
}//end of while
getche();
}//end of main
frrossk 2 Posting Whiz in Training
plz guide me soon so that i submit my assignment on saturday
It would be better if you would specify exactly where in the program you run into troubles; and post exactly the pieces of code where you get errors...
varunrathi 0 Light Poster
I Agree With Frrossk B`coz Ur Program Is Too Large To Search For Any Error.
Keiyentai 0 Newbie Poster
I tried to compile iti n BloodSheds Dev C++ and I got 27 different errors.
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.