//WAC++ program to create class named “Employee” with following details as
eid,ename,designation,salary etc. Write following operations over one employee record.
//over the employee class perform following operation
//1. insert employee details
//2. display employee details/
//3. update employee salary or increase employee salary by 20%
//4. update employee designation AP to Professor.
#include<iostream>
#include<string.h>
using namespace std;
class Employee
{
int eid,salary;
char ename[20],desgn[20];
public:
void insert();
void display();
void update_salary(float usal)
{
salary=salary+(salary*(usal/100));
}
void update_desgn(char d[])
{
strcpy(desgn,d);
}
};
void Employee::insert()
{
cout<<"Enter the Employee Id:";
cin>>eid;
cout<<"Enter the Employee Name:";
cin>>ename;
cout<<"Enter the Designation:";
cin>>desgn;
cout<<"Enter the Salary:";
cin>>salary;
}
void Employee::display()
{
cout<<endl<<eid<<"\t"<<ename<<"\t"<<desgn<<"\t\t"<<salary;
}
main()
{
Employee e1,e2;
[Link]();
[Link]();
cout<<endl<<"EID\tENAME\tDESIGNATION\tSALARY"<<endl;
cout<<"---------------------------------"<<endl;
[Link]();
[Link]();
e1.update_salary(10);
e1.update_desgn("Professor");
e2.update_salary(20);
e2.update_desgn("AssociateProfessor");
cout<<endl<<endl<<"EID\tENAME\tDESIGNATION\tSALARY"<<endl;
cout<<"---------------------------------"<<endl;
[Link]();
[Link]();
return 0;
}
Q. Write an Object Oriented Program in C++ with class Account with following attributes such
as acno, achodlers name, address, contact_no and Amount. Write following operations over one
account holder record,
i. Reading account information.
ii. Printing account info (show in tabular format)
iii. Deposit amount in Account
iv. Withdraw amount from account
#include<iostream>
#include<stdio.h>
using namespace std;
class Account
{
int acno,contact_no,amount;
char name[30],address[30];
public:
void insert();
void display();
void deposit();
void withdraw();
};
void Account::insert()
{
cout<<"Enter the Account Number:";
cin>>acno;
cout<<"\nEnter the Name:";
fflush(stdin);
[Link](name,30);
cout<<"\nEnter the Contact Number:";
fflush(stdin);
cin>>contact_no;
cout<<"\nEnter the Address:";
fflush(stdin);
[Link](address,30);
cout<<"\nEnter the amount:";
cin>>amount;
}
void Account::display()
{
cout<<endl<<acno<<"\t"<<name<<"\t"<<contact_no<<"\t"<<address<<"\t"<<amount;
}
void Account::deposit()
{
int amt;
cout<<"\nEnter the Deposited Amount:";
cin>>amt;
amount=amount+amt;
display();
cout<<endl<<"Amount Deposited Successfully"<<endl;
}
void Account::withdraw()
{
int amt;
cout<<"\nEnter the Withdraw Amount:";
cin>>amt;
amount=amount-amt;
display();
cout<<endl<<"Amount Withdraw Successfully"<<endl;
}
main()
{
Account _acc;
_acc.insert();
cout<<endl<<"Acno\tNAME\tContact_no\tAddress\tAmount"<<endl;
cout<<"------------------------------------------------"<<endl;
_acc.display();
_acc.deposit();
_acc.withdraw();
return 0;
}
Q. Create a class staff having fields: Staff id ,
name, department, designation, salary. Write
a menu driven program for:
1) To accept the record one by one
2) To display the entire record
3) To sort the record by name
4) Find the sum of the salary designation wise
Staff id must be auto-incremented and
department must be computer science
Q1. Create a class to specify data on students given below:
Roll number, Name, Department, Course, Year of joining
Assume that there are not more than 300 students in the college.
(i) Write a C++ program to print details of all student record that joined in a particular year
using the concept of passing object as a method argument.
(ii) Write a C++ program to print the details of all student record in ascending order basis of
student name.
Note: Roll Number should be auto incremented and Department name should be “Computer
Science”
Q: Define a STUDENT class with Id, name and marks in 3 tests of a subject. Declare an array
of 10 student objects. Using appropriate functions, find the average of two better marks for
each student. Print Id, Name and the average marks of all the students.
/*
Q. In a class there are 10 students. Each student is supposed to appear in 3 tests.
Write a program using
two-dimensional arrays to print total marks and average marks obtained by each student.
*/
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
int M[2][3]={{47,75,80},{52,81,76}};
int tm,i,j;
for ( i = 0; i < 2; i++ )
{
tm=0;
for ( j = 0; j < 3; j++ )
{
tm+=M[i][j];
}
float pm=(float) tm/3;
cout<<setprecision(2)<<fixed;
cout<<endl<<"Student "<<i+1<<" Total Marks ="<<tm;
cout<<endl<<"% Marks Student "<<i+1<<" = "<<pm<<endl;
}
return 0;
}
Q: Develop a C++ program to create class named “Employee” with following attributes such as employee
id, employee name, designation, salary etc.
Write following operations over “N” numbers of employee record.
1. Insert employee details
2. Display employee details
3. Update employee salary or increase employee salary by 20% on the basis of Employee ID
4. Update employee designation on the basis of Employee ID.