#include <stdio.h>
#include <string.h>
#include <conio.h>
bool check_assignment_marks(float amarks)
{
if(amarks>=0&&amarks<=5)
{
return true;
}
else
{
return false;
}
}
bool check_quiz_marks(float qmarks)
{
if(qmarks>=0&&qmarks<=5)
{
return true;
}
else
{
return false;
}
}
bool check_project_marks(float pmarks)
{
if(pmarks>=0&&pmarks<=10)
{
return true;
}
else
{
return false;
}
}
bool check_midterm_marks(float mmarks)
{
if(mmarks>=0&&mmarks<=30)
{
return true;
}
else
{
return false;
}
}
bool check_final_marks(float fmarks)
{
if(fmarks>=0&&fmarks<=50)
{
return true;
}
else
{
return false;
}
}
float calculate_total_marks(float assignment, float quiz, float project, float midterm, float final)
{
float total=assignment+quiz+project+midterm+final;
return total;
}
char calculate_grade(float total_marks)
{
if(total_marks>=90)
{
return 'A';
}
else if(total_marks<90&&total_marks>=75)
{
return 'B';
}
else if(total_marks<75&&total_marks>=60)
{
return 'C';
}
else if(total_marks<60&&total_marks>=50)
{
return 'D';
}
else
{
return 'F';
}
}
int main()
{
char student_name[100];
char student_grade;
char student_roll_number[10];
float student_total_marks=0;
float assignment_marks=0, quiz_marks=0, project_marks=0, midterm_marks=0, final_marks=0;
bool check=false;
puts("Enter your name: ");
gets(student_name);
puts("Enter your Roll Number: ");
gets(student_roll_number);
puts("Enter your Assigments Marks (max marks are 5): ");
scanf("%f",&assignment_marks);
while(1)
{
check=check_assignment_marks(assignment_marks);
if(check==true)
{
break;
}
else
{
puts("Please enter Assignment Marks from 0 to 5: ");
assignment_marks=0;
scanf("%f",&assignment_marks);
}
}
puts("Enter your Quizes Marks(max marks are 5): ");
scanf("%f",&quiz_marks);
while(1)
{
check=check_quiz_marks(quiz_marks);
if(check==true)
{
break;
}
else
{
puts("Please enter Quiz marks from 0 to 5: ");
quiz_marks=0;
scanf("%f",&quiz_marks);
}
}
puts("Enter your Project Marks (max marks are 10): ");
scanf("%f",&project_marks);
while(1)
{
check=check_project_marks(project_marks);
if(check)
{
break;
}
else
{
puts("Please enter Project marks from 0 to 10: ");
project_marks=0;
scanf("%f",&project_marks);
}
}
puts("Enter your Midterm Paper Marks (max marks are 30): ");
scanf("%f",&midterm_marks);
while(1)
{
check=check_midterm_marks(midterm_marks);
if(check)
{
break;
}
else
{
puts("Please enter Midterm marks from 0 to 30: ");
midterm_marks=0;
scanf("%f",&midterm_marks);
}
}
puts("Enter your Final Paper Marks (max marks are 50): ");
scanf("%f",&final_marks);
while(1)
{
check=check_final_marks(final_marks);
if(check)
{
break;
}
else
{
puts("Please enter Final marks from 0 to 50: ");
final_marks=0;
scanf("%f",&final_marks);
}
}
student_total_marks=calculate_total_marks(assignment_marks,quiz_marks,project_marks,midterm_marks,final_marks);
student_grade=calculate_grade(student_total_marks);
if(student_grade=='F')
{
puts("Sorry! You have failed the exam. Your result is: ");
printf("Total Marks = %f\n",student_total_marks);
printf("Grade = %c\n\n",student_grade);
}
else
{
puts("Congratulations! You have passed the exam. Your result is: ");
printf("Total Marks = %f\n",student_total_marks);
printf("Grade = %c\n",student_grade);
}
puts("\n\nPress any key to close program");
char ch=getch();
}
0 comments:
Post a Comment