You are on page 1of 5

SARDAR VALLBHBHAI PATEL

INSTITUTE OF TECHNOLOGY , VASAD

C ++ Coding Club Workshop

Assignment 5

Name : Soham Patel

Enrollment No : 190410116100

Class : SY IT 3
Write a C++ program on STUDENT REPORT CARD has student class
with data members like roll no, name, marks and grade. Member
functions in this class are used for accept / display details of students
and a function to calculate grade based on marks obtained by student.

#include<iostream>
using namespace std;

class student
{
int rollno;
char name[50];
int phy_marks, che_marks, math_marks;
float per;
char grade;
void calculate();

public:
void intro();
void getdata();
void showdata();
};

void student :: calculate()


{
per = (phy_marks + che_marks + math_marks)/3;
if(per >= 90)
grade = 'A';
else if(per >= 70 && per < 90)
grade = 'B';
else if(per >= 60 && per < 70)
grade = 'c';
else
grade = 'F';
}

void student :: intro()


{
cout<<"\n\n\n\t\t STUDENT";
cout<<"\n\n\t\tREPORT CARD";
cout<<"\n\n\t\t PROJECT";
cout<<"\n\n\n\tMade By : SOHAM PATEL";
cin.get();
}

void student :: getdata()


{
cout<<"\n\n\tEnter the Name of Student : ";
cin>>name;
cout<<"\tEnter the Roll No of Student : ";
cin>>rollno;
cout<<"\tEnter the marks in Physics out of 100 : ";
cin>>phy_marks;
cout<<"\tEnter the marks in Chemistry out of 100 : ";
cin>>che_marks;
cout<<"\tEnter the marks in Maths out of 100 : ";
cin>>math_marks;
calculate();
}

void student :: showdata()


{
cout<<"\n\n\tName of student : "<<name;
cout<<"\n\n\tRoll number of student : "<<rollno;
cout<<"\n\n\tMarks in Physics : "<<phy_marks;
cout<<"\n\n\tMarks in Chemistry : "<<che_marks;
cout<<"\n\n\tMarks in Maths : "<<math_marks;
cout<<"\n\n\tPercentage of student is : "<<per;
cout<<"\n\n\tGrade of student is : "<<grade<<endl;
}

int main()
{
student std;
std.intro();
std.getdata();
std.showdata();

return 0;
}

You might also like