Class for Student Details
#include<iostream>
#include<iomanip>
using namespace std;
class Student
{
private:
float percentage;
int fees;
public:
char Name[50];
int Age;
void inputData();
void displayData();
};
void Student::inputData()
{
float x1;
int x2;
cout<<"Enter the percentage of the student ";
cin>>x1;
cout<<"Enter the fees of the student ";
cin>>x2;
percentage=x1;
fees = x2;
}
void Student::displayData()
{
cout<<"Name : "<<Name<<endl;
cout<<"Age : "<<Age<<endl;
cout<<"Percentage : "<<fixed<<setprecision(1)<<percentage<<endl;
cout<<"Fees : "<<fees<<endl;
}
int main()
{
Student a;
cout<<"Enter name of the student ";
cin.get(a.Name,50);
cout<<"Enter age of the student ";
cin>>a.Age;
a.inputData();
a.displayData();
return 0;
}
Comments
Post a Comment