Private members :
Name 20 characters
Subject 10 characters
Basic, DA, HRA float
Salary float
Calculate ( ) function computes the salary and returns it.
Public members :
Readdata ( ) function accepts the data values and invokes the calculate function.
Displaydata ( ) function prints the data on the screen.
PROGRAM:
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
class student {
private:
char name[20];
char subject[10];
float basic;
float da;
float hra;
float salary;
float calculate();
public:
void readdata();
void displaydata();
};
float student::calculate() {
return basic+da+hra;
}
void student::readdata() {
cout<<"\nEnter your name: ";
gets(name);
cout<<"\nEnter your basic salary: ";
cin>>basic;
cout<<"\nEnter your daily allowance: ";
cin>>da;
cout<<"\nEnter your Hourse Rent Allowance: ";
cin>>hra;
salary=calculate();
}
void student::displaydata() {
cout<<"\nYour name: "<<name;
cout<<"\nYour total salary: "<<calculate();
}
void main() {
clrscr();
student s1;
s1.readdata();
s1.displaydata();
getch();
}
1 comment:
Nice Blog Thanks for share it!! For more information click here:-
National Institute of Open Schooling
Robotics Courses
Personality Development Courses for Kids
Ethical Hacking Training Centre
Learn RSCIT
MS-Office Courses
Interior Designing Course after 12th
Post a Comment