A PROGRAM TO CALCULATE G.P.A GPA Calculation in C C++ Programming Language C Programming GPA Calculator using Loop File Calculate GPA
#include<stdio.h>
#include<conio.h>
#include<ctype.h>
#include<text.h> /* HEADER FILE[TEXT INCLUSION],[73]*/
# define READ(n) scanf("%f",&n) /* MACRO USED LINE=> [89,97,107] */
HORIZONTAL_LINES(int, int, int, int); /* [ DRAWING HORIZONTAL LINES] */
VERTICLE_LINES(int, int, int, int); /* [DRAWING VERTICLE LINES] */
char grade (int ); /* FUNCTION[GRADE CALCULATION] */
void ONLY_ALPHABETS(); /* FUNCTION [ALPHABET INPUT] */
void ONLY_DIGITS(); /* FUNCTION [DIGIT INPUT] */
float gpa=0.0; /* GLOBAL [207] */
void main(void)
{
char user_name[25];
int mid_loop,final_loop,grade_loop; /* FOR LOOP VARIABLES [84,86] */
float marks,total; /* GPA CALCULATE VARIABLE[85,89] */
int horizontal,verticle;
PROGRAM_TEXT;
float result=0.0
// PROGRAM_TEXT;
//clrscr();
//gotoxy(20,25);
printf("ENTER YOUR NAME\t");
HORIZONTAL_LINES(61,219,38,23); /* USER NAME'S INPUT BORDERS=>1 */
VERTICLE_LINES(28,222,37,23);
HORIZONTAL_LINES(61,219,38,28);
VERTICLE_LINES(27,222,61,24);
HORIZONTAL_LINES(58,196,40,26); /* END => 1 */
gotoxy(40,25);
scanf("%s",user_name);
clrscr();
// PROGRAM_TEXT;
gotoxy(35,2);
HORIZONTAL_LINES(51 ,220,31,2); /* EXTERNAL BORDERS =>2 */
VERTICLE_LINES(6,219,31,3);
HORIZONTAL_LINES(51,220,32,5); /* HORIZONTAL_LINES == X AXIS BORDERS */
VERTICLE_LINES(6,219,51,3);
gotoxy(2,5);
printf("\n%c",201);
HORIZONTAL_LINES(79,205,2,6);
printf("%c",187);
HORIZONTAL_LINES(79,205,2,50);
printf("%c",188);
VERTICLE_LINES(49,186,1,6); /* VERTICLE LINES == Y AXIS BORDERS */
printf("\b%c",200);
VERTICLE_LINES(48,186,80,6); /* END =>2 */
// PROGRAM_TEXT;
gotoxy(2,16); /* INTERNAL BORDERS =>3 */
printf("%c",201);
HORIZONTAL_LINES(78,205,3,16);
printf("%c",187);
HORIZONTAL_LINES(78,205,3,44);
printf("%c",188);
VERTICLE_LINES(44,186,2,17);
printf("\b%c",200);
VERTICLE_LINES(43,186,79,17); /* END =>3 */
//int horizontal,verticle;
for(horizontal=20;horizontal<=42;horizontal+=4)/*HORIZONATAL TABLE LINE =>4*/
HORIZONTAL_LINES(78,196,3,horizontal);
for(verticle=7;verticle<=77;verticle+=13) /* VERTICLE TABLE LINE =>5 */
{
if(verticle==33)
printf("");
else
VERTICLE_LINES(43,179,verticle,17);
} /* END =>5 */
HORIZONTAL_LINES(60,196,29,8);
HORIZONTAL_LINES(60,196,29,12);
HORIZONTAL_LINES(78 ,196,74,48);
/* ////////////////////////-ENTIRE PROGRAM TEXT-/////////////////////////// */
// PROGRAM_TEXT;
gotoxy(30,7);
ONLY_ALPHABETS(); /* CALL FOR ALPHA INPUT ONLY */
gotoxy(32,11);
ONLY_DIGITS(); /* DIGIT */
gotoxy(35,11);
ONLY_ALPHABETS(); /* ALPHA */
gotoxy(38,11);
ONLY_ALPHABETS(); /* DIGIT */
gotoxy(43,11);
ONLY_DIGITS(); /* CALL FOR DIGIT INPUT ONLY */
/* ///////////////////////-MID & FINAL MARKS INPUT-/////////////////////// */
for(mid_loop=23,grade_loop=23;mid_loop<=43;mid_loop+=4,grade_loop+=4)
{ total=0.0;
for( final_loop=52;final_loop<=65;final_loop+=13)
{ // float result=0.0
gotoxy(final_loop,mid_loop);
READ(marks);
if((marks>40||marks<0)&&final_loop==52) /* 0 <= MARKS <= 40 FOR MID (1) */
{
do
{
marks=0;
gotoxy(final_loop,mid_loop);
printf("%c%c%c\b\b\b",255,255,255);
READ(marks);
}while(marks>40||marks<0); /* END (1) */
}
else if((marks>60||marks<0)&&final_loop==65) /*0<= MARKS <= 60 FOR FINAL*/
{ /* (2) */
do
{
marks=0;
gotoxy(final_loop,mid_loop);
printf("%c%c%c\b\b\b",255,255,255);
READ(marks);
} while(marks>60||marks<0); /* END (2) */
}
total+=marks;
}
gotoxy(76,grade_loop);
printf("%c",grade(total));
// float result=0.0;
result=(result+gpa)/6;
if(mid_loop==43)
{
gotoxy(74,47);
printf("%.2f",result);
}
}
getch();
}
/* ====================-FUNCTION DRAWING HORIZONTAL LINES-===================
=============== CALL [26,28,30,35,41,43,51,53,61,69,70,71] ================ */
HORIZONTAL_LINES(int limit, int lines, int x_axes, int y_axes)
{
int xloop;
for(xloop=x_axes ; xloop<=limit ; xloop++)
{
gotoxy(xloop,y_axes);
printf("%c",lines);
}
}
/*=========================-FUNCTION DRAWINGVERTICLE LINES-==================
====================== CALL[27,29,36,3845,47,55,57,67] =================== */
VERTICLE_LINES(int limit, int lines, int x_axes, int y_axes)
{
int yloop;
for(yloop=y_axes ; yloop<=limit ; yloop++)
{
gotoxy(x_axes,yloop);
printf("%c",lines);
}
}
/* /////////////////////////-ONLY ALPHABET INPUT-/////////////////////////////
///////////////////////////////-CALL[75,79,81]-//////////////////////////// */
void ONLY_ALPHABETS()
{
char ch;
do
{
if(isalpha(ch)||isspace(ch))
;
else
printf("\b%c\b",255);
} while((ch=getche())!='\r');
}
/* ////////////////////-FUNCTION ONLY DIGIT INPUT-///////////////////////////
////////////////////////////////-CALL[77,83]-//////////////////////////// */
void ONLY_DIGITS()
{
char ch;
do
{
if(isdigit(ch))
;
else
printf("\b%c\b",255);
} while((ch=getche())!='\r');
}
/* ////////////////////////-G.P.A CALCULATION FUNCTION-//////////////////////
//////////////////////////////// - CALL [115]- /////////////////////////// */
char grade(int total)
{
float grade_points;
char grade;
if(total>=80)
{
grade='A';
grade_points=4.0;
}
else if(total>=75&&total<80)
{
grade='B';
printf(" +");
printf("\b\b");
grade_points=3.5;
}
else if(total>=70&&total<75)
{
grade='B';
grade_points=3.0;
}
else if(total>=65&&total<70)
{
grade='C';
printf(" +");
printf("\b\b");
grade_points=2.5;
}
else if(total>=60&&total<65)
{
grade='C';
grade_points=2.0;
}
else
{
printf("F");
grade_points=0.0;
}
gpa=gpa+grade_points;
return(grade);
}
/* =============================-END PROGRAM-============================== */
0 comments:
Post a Comment