Nothing Special   »   [go: up one dir, main page]

Create Table Manager

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

QP0923FN04

1. Write a C++ program to design a base class Person (name,


address, phone_no). Derive a class Employee (eno, ename)
from Person. Derive a class Manager (designation, department
name, basic-salary) from Employee. Write a menu driven
program to:

a. Accept all details of 'n' managers.

#include<iostream>
using namespace std;
class Person //Base Class
{
protected:
char pname[50], address[100];
int phone_no;
};
//Class Employee - Derived Class. Derived from Class Person and Base Class
of Manager
class Employee : public Person
{
public:
int eno;
char ename[50];
};
class Manager : public Employee //Class Manager - Derived Class. Derived
from Class Employee
{
public:
char designation[50], deptname[100];
float basic_salary;
public:
void accept_details()
{
cout<<"\n Enter Details of Manager ";
cout<<"\n -------------------------- ";
cout<<"\n Enter Employee No. : ";
cin>>eno;
cout<<"\n Enter Name : ";
cin>>ename;
cout<<"\n Enter Address : ";
cin>>address;
cout<<"\n Enter Phone No. : ";
cin>>phone_no;
cout<<"\n Enter Designation : ";
cin>>designation;
cout<<"\n Enter Department Name : ";
cin>>deptname;
cout<<"\n Enter Basic Salary : ";
cin>>basic_salary;
}
};
int main()
{
int i,cnt,temp;
Manager man[100];
cout<<"\n How Many Managers You Want to Enter? : ";
cin>>cnt; //Accept details for 'n' managers
for(i=1;i<=cnt;i++)
{
man[i].accept_details();
}
temp=0;
for(i=1;i<=cnt;i++)
{
if(man[temp].basic_salary<man[i].basic_salary)
temp=i;
}
cout<<"\n Manager with Highest Salary is :
"<<man[temp].basic_salary;
cout<<" \n And, Manager Name is : "<<man[temp].ename;
return 0;
}
Output:

2.

1.

CREATE TABLE MANAGER


(
Mgr_ID nvarchar(5), PRIMARY KEY,
Name nvarchar(25) NOT NULL,
Dept_ID int(5) FOREIGN KEY,
Contact_No int(10),
Salary int(10),
);

CREATE TABLE DEPARTMENT


(
Dept_ID int(5), PRIMARY KEY,
Dept_Name nvarchar(10) NOT NULL,
);

2. Insert 5 records into each table


2) "INSERT INTO MANAGER (MGR_ID, NAME, DEPT_ID, CONTACT NO, SALARY) VALUES
(100, “SHYAM”,T101, 1234567, 60000);

"INSERT INTO MANAGER (MGR_ID, NAME, DEPT_ID, CONTACT NO, SALARY) VALUES
(101, “SEEMA”,T102, 2345678, 50000);

"INSERT INTO MANAGER (MGR_ID, NAME, DEPT_ID, CONTACT NO, SALARY) VALUES
(102, “RITA”,T103, 4567890, 35000);

"INSERT INTO MANAGER (MGR_ID, NAME, DEPT_ID, CONTACT NO, SALARY) VALUES
(100, “PAUL”,T104, 12347890, 45000);

"INSERT INTO MANAGER (MGR_ID, NAME, DEPT_ID, CONTACT NO, SALARY) VALUES
(100, “THOMAS”,T105, 1234500, 30000);

"INSERT INTO DEPARTMENT (DEPT_ID, DEPT_NAME,) VALUES (T101, “OPERATIONS”);

"INSERT INTO DEPARTMENT (DEPT_ID, DEPT_NAME,) VALUES (T102, “SALES”);

"INSERT INTO DEPARTMENT (DEPT_ID, DEPT_NAME,) VALUES (T103, “HR”);

"INSERT INTO DEPARTMENT (DEPT_ID, DEPT_NAME,) VALUES (T104, “RETAIL”);

"INSERT INTO DEPARTMENT (DEPT_ID, DEPT_NAME,) VALUES (T101, “FINANCE”);

3. UPDATE MANAGER SET SALARY = SALARY + 2500 WHERE SALARY < 50000;

4. SELECT * from MANAGER where SALARY in (select max(SALARY) from MANAGER


group by MANAGER);

5. SELECT * from MANAGER where DEPT_NAME = SALES);

You might also like