[go: up one dir, main page]

0% found this document useful (0 votes)
13 views8 pages

Home Task 09

Uploaded by

f24609010
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views8 pages

Home Task 09

Uploaded by

f24609010
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

National University of Technology

Computer Science Department


Semester fall – 2024
Program: Cyber Security
Course: PF

Home Task 09

Submitted to: Submitted by:


Sir Rizwan Yousaf Manahil Aftab
F24609060
NATIONAL UNIVERSITY OF TECHNOLOGY
Main I.J.P Road, Sector I-12 Islamabad

CS 120 Programming Fundamentals

Instructor Name: Sir Rizwan Yousaf Department: Computer Science

Batch: BSCY 2024 Session: Fall 2024

Name: Manahil Aftab Reg No: F24609060

HOME TASK 09
Task 01:
Translate the following problem into an Efficient & Complete C++ program.
Problem Statement:
NUTECH is planning to move the employee records from legacy register logging to
an automated program. You need to translate the employee management
process into an Efficient & Complete C++ program for users to use it. [Use
functions for all the Options]
Student record keeping –

a. Employee Name [String]


b. Fathers Name [String]
c. CNIC (with dashes incorporated)
d. Address [String]
e. Year Joined Service [Integer]
f. Pay Grade [Integer, ranging from 1 to 15]
g. Employee ID. [An Integer Value] 1234 etc
h. Basic Salary (Float)
CODE
#include<iostream>
#include<cstring>
#include<iomanip>
using namespace std;

const int MAX_EMPLOYEES = 100;


char full_Name[MAX_EMPLOYEES][50];
char father_name[MAX_EMPLOYEES][50];
char cnic[MAX_EMPLOYEES][20];
char address[MAX_EMPLOYEES][100];
int year_joined[MAX_EMPLOYEES];
int pay_grade[MAX_EMPLOYEES];
int employee_id[MAX_EMPLOYEES];
float basic_salary[MAX_EMPLOYEES];
int employee_count = 0;

void addEmployeeRecord()
{
if (employee_count >= MAX_EMPLOYEES)
{
cout << "Employee record limit reached!" << endl;
}

cout << "Enter Employee Name: ";


cin.ignore();
cin.getline(full_Name[employee_count], 50);

cout << "Enter Father's Name: ";


cin.getline(father_name[employee_count], 50);

cout << "Enter CNIC (with dashes): ";


cin.getline(cnic[employee_count], 20);

cout << "Enter Address: ";


cin.getline(address[employee_count], 100);

cout << "Enter Year Joined Service: ";


cin >> year_joined[employee_count];
cout << "Enter Pay Grade (1-15): ";
cin >> pay_grade[employee_count];

cout << "Enter Employee ID: ";


cin >> employee_id[employee_count];

cout << "Enter Basic Salary: ";


cin >> basic_salary[employee_count];

employee_count++;
cout << "Employee record added successfully!" <<
endl;
}

void searchEmployeeRecord() {
int id;
cout << "Enter Employee ID to search: ";
cin >> id;

for (int i = 0; i < employee_count; i++) {


if (employee_id[i] == id) {
cout << "Employee Found!" << endl;
cout << "Name: " << full_Name[i] << endl;
cout << "Father's Name: " << father_name[i] <<
endl;
cout << "CNIC: " << cnic[i] << endl;
cout << "Address: " << address[i] << endl;
cout << "Year Joined: " << year_joined[i] << endl;
cout << "Pay Grade: " << pay_grade[i] << endl;
cout << "Employee ID: " << employee_id[i] <<
endl;
cout << "Basic Salary: " << basic_salary[i] << endl;
return;
}
}
cout << "Employee not found!" << endl;
}

void viewAllEmployeeRecords() {
if (employee_count == 0) {
cout << "No employee records available!" << endl;
return;
}

cout << setw(10) << "ID" << setw(20) << "Name" <<
setw(20) << "Father's Name" << setw(15) << "Pay Grade"
<< setw(15) << "Basic Salary" << endl;
for (int i = 0; i < employee_count; i++) {
cout << setw(10) << employee_id[i]
<< setw(20) << full_Name[i]
<< setw(20) << father_name[i]
<< setw(15) << pay_grade[i]
<< setw(15) << basic_salary[i] << endl;
}
}

void viewEmployeesByPayGrade() {
int grade;
cout << "Enter Pay Grade to view employees: ";
cin >> grade;

bool found = false;


cout << "Employees with Pay Grade " << grade << ":"
<< endl;
for (int i = 0; i < employee_count; i++) {
if (pay_grade[i] == grade) {
cout << "ID: " << employee_id[i] << ", Name: " <<
full_Name[i] << endl;
found = true;
}
}
if (!found) {
cout << "No employees found with Pay Grade " <<
grade << endl;
}
}

void computeTakeHomeSalary() {
int id;
cout << "Enter Employee ID to compute take-home
salary: ";
cin >> id;

for (int i = 0; i < employee_count; i++) {


if (employee_id[i] == id) {
float house_rent_allowance = 0.45 *
basic_salary[i];
float medical_allowance = 0.05 * basic_salary[i];
float conveyance_allowance = 0.10 *
basic_salary[i];
float take_home_salary = basic_salary[i] +
house_rent_allowance + medical_allowance +
conveyance_allowance;

cout << "Take-home Salary for Employee ID " << id


<< " is: " << take_home_salary << endl;
return;
}
}
cout << "Employee not found!" << endl;
}

int main()
{
cout<<"Manahil Aftab\t\tF24609060\t\tBS Cyber\t\tPF";
int choice;

do {
cout << "\nMenu:\n";
cout << "Press 1. Add Employee Record\n";
cout << "Press 2. Search Employee Record\n";
cout << "Press 3. View All Employee Records\n";
cout << "Press 4. View All Employees of a Specific
Pay Grade\n";
cout << "Press 5. Compute the Take-home Salary of
an Employee\n";
cout << "Press 6. Exit\n";
cout << "Enter your choice: ";
cin >> choice;
switch (choice)
{
case 1:
addEmployeeRecord();
break;
case 2:
searchEmployeeRecord();
break;
case 3:
viewAllEmployeeRecords();
break;
case 4:
viewEmployeesByPayGrade();
break;
case 5:
computeTakeHomeSalary();
break;
case 6:
cout << "Exiting the program. Goodbye!" <<
endl;
break;
default:
cout << "Invalid choice! Please try again." <<
endl;
}
}
while (choice != 6);
cout<<"Manahil Aftab\t\tF24609060\t\tBS Cyber\t\tPF";
return 0;
}
OUTPUT

You might also like