CS304 Assignment 2 Solution 2021 - Object Oriented Programming Assignment

 

CS304 Assignment 2 Solution Spring 2021

In This Post Provide a Complete Correct CS304 Assignment 2 Solution 2021. Object-Oriented Programming Assignment Solution. Download CS304 Assignment 2 Solution Spring 2021.


Check Here Latest CS304 Solution 






CS304 Assignment 2 Solution Spring 2021




Total Marks: 20

Due Date: 6-June-2021

FULLY CORRECT SOLUTION SS PROVIDE BELOW


Assignment Objective:
Write a Program in CPP for a company to keep record employee details.

CODE SOLUTION:

// Any Problem or Help freely to Contact WhatsApp 03162965677

// A Solution Provide by VUAnswer.com

 // Your Truly Helper

#include<iostream>

#include<conio.h>

using namespace std;

int id=8248001,i=0;

class Person

{

private:

string FirstName;

string LastName;

int PersonalId;

double Salary;

public:

void set_FirstName(string fn);

void set_LastName(string ln);

void set_PersonalId(int z);

void set_Salary(double sal);

string get_FirstName();

string get_LastName();

int get_PersonalId();

double get_Salary();

};

class HRM

{

private:

Person p[15];

public:

void AddPerson();

void DeletePerson();

void UpdatePerson();

};

void Person::set_FirstName(string fn)

{

FirstName = fn;

}

void Person::set_LastName(string ln)

{

LastName = ln;

}

void Person::set_PersonalId(int z)

{

PersonalId = z;

}

void Person::set_Salary(double sal)

{

Salary = sal;

}

string Person::get_FirstName()

{

return FirstName;

}

string Person::get_LastName()

{

return LastName;

}

int Person::get_PersonalId()

{

return PersonalId;

}

double Person::get_Salary()

{

return Salary;

}

void HRM::AddPerson()

{

string fn,ln;

double sal;

cout<<"\n\n First Name : ";

cin>>fn;

p[i].set_FirstName(fn);

cout<<" Last Name : ";

cin>>ln;

// solution by vuanswer.com

p[i].set_LastName(ln);

p[i].set_PersonalId(id);

id++;

cout<<" How much is his/her Salary? =";

cin>>sal;

p[i].set_Salary(sal);

i++;

cout<<"\n\n New employee information added in the system";

cout<<"\n\n First Name     Last Name     Personal ID     Salary per year (Rupees)";

cout<<"\n -----------  ------------- ---------------    -----------------------";

for(int a=0;a<i;a++)

{

cout<<"\n "<<p[a].get_FirstName()<<"          "<<p[a].get_LastName()<<"          "<<p[a].get_PersonalId()<<"               "<<p[a].get_Salary();

}

}

void HRM::DeletePerson()

{

int t_id;

char x;

cout<<"\n\n ID of Employee to Remove : ";

cin>>t_id;

cout<<"\n Do you want to really delete employee (Y,N) : ";

cin>>x;

if(x == 'Y' || x == 'y')

{

for(int a=0;a<i;a++)

{

if(p[a].get_PersonalId() == t_id)

{

for(int k=a;k<i;k++)

{

p[k].set_FirstName(p[k+1].get_FirstName());

p[k].set_LastName(p[k+1].get_LastName());

p[k].set_PersonalId(p[k+1].get_PersonalId());

p[k].set_Salary(p[k+1].get_Salary());

}

cout<<"\n\n Delete employee information from the system";

i--;

}

}

}

cout<<"\n\n First Name     Last Name     Personal ID     Salary per year (Rupees)";

cout<<"\n -----------  ------------- ---------------    -----------------------";

for(int a=0;a<i;a++)

{

cout<<"\n "<<p[a].get_FirstName()<<"          "<<p[a].get_LastName()<<"          "<<p[a].get_PersonalId()<<"               "<<p[a].get_Salary();

}

}

void HRM::UpdatePerson()

{

int t_id,x;

double sal;

char choice;

string fn,ln;

// Any problem or help us freely whatsapp 03162965677

// VU Answer

cout<<"\n\n Employee ID for modify information : ";

cin>>t_id;

do{

cout<<"\n\n 1. First Name";

cout<<"\n 2. Last Name";

cout<<"\n 3. Salary";

cout<<"\n\n Number of Field for modify : ";

cin>>x;

for(int a=0;a<i;a++)

{

if(p[a].get_PersonalId() == t_id)

{

if(x == 1)

{

cout<<"\n First Name : ";

cin>>fn;

p[a].set_FirstName(fn);

}

else if(x == 2)

{

cout<<"\n Last Name : ";

cin>>ln;

p[a].set_LastName(ln);

}

else if(x == 3)

{

cout<<"\n Salary : ";

cin>>sal;

p[a].set_Salary(sal);

}

cout<<"\n\n Modify employee information from the system";

}

}

cout<<"\n\n Do you want modify another field (Y,N) : ";

cin>>choice;

}while(choice == 'Y' || choice == 'y');

cout<<"\n\n First Name     Last Name     Personal ID     Salary per year (Rupees)";

cout<<"\n -----------  ------------- ---------------    -----------------------";

for(int a=0;a<i;a++)

{

cout<<"\n "<<p[a].get_FirstName()<<"          "<<p[a].get_LastName()<<"          "<<p[a].get_PersonalId()<<"               "<<p[a].get_Salary();

}

}

main()

{

HRM obj;

int choice;

char x;

p:

cout<<"Welcome to Human Resource Management (HRM) Software of Company."<<endl;

cout<<"------------------------(VUAnswer.com)-------------------------"<<endl;

cout<<""<<endl;

cout<<"To do specific task please select one of the following given command"<<endl;

cout<<""<<endl;

cout<<"\n\n\t1. Add New Employee";

cout<<"\n\t2. Delete Employee Information";

cout<<"\n\t3. Update Employee Information";

cout<<"\n\t4. Quit";

cout<<"\n\n\tEnter Your Choice : ";

cin>>choice;

switch(choice)

{

case 1:

cout<<"\n\n Enter the information of the new employee";

do{

obj.AddPerson();

cout<<"\n\n Do you want to add another employee (Y,N) : ";

cin>>x;

}while(x == 'Y' || x == 'y');

break;

case 2:

obj.DeletePerson();

break;

case 3:

obj.UpdatePerson();

break;

case 4:

exit(0);

default:

cout<<"\n\n\tInvalid Value...Please Try Again...";

}

goto p;

}



CODE RESULT SCREENSHOT VERIFY





PLEASE NOTE:

Don't copy-paste the same answer.

Make sure you can make some changes to your solution file before submitting copy-paste solution will be marked zero.

If you found any mistake then correct yourself and inform me.

Before submitting an assignment check your assignment requirement file.

If you need some help and question about files and solutions.



CS304 Assignment 2 Solution 2021
CPP Assignment Idea and Solution
Download CS304 Assignment 1 Solution Spring 2021 CPP File
Object-Oriented Programming Assignment Solution



Post a Comment

0 Comments