Click here to Skip to main content
15,031,510 members
Please Sign up or sign in to vote.
1.00/5 (5 votes)
See more:
Question is: Define a class with an employee name by encapsulation, and the methods in the properties of the Employee class are as follows.
Features(data members): define employee name, surname and salary information as members who can only access it from within the employee class
Methods: the increase that the employee will receive is 10 percent of his salary. Create a function that calculates this increase so that it can be accessed from anywhere.
c++ program that calculates the amount of raise that this employee whose name is Pelin Yilmaz in the main function is entered as 3000 dollar and prints the employee's name surname salary and raise amount information on the screen.

What I have tried:

I could not do this c++ question in a programming exam
Posted
Updated 19-Jan-21 7:21am
Comments
Patrice T 19-Jan-21 1:49am
   
"I could not do this c++ question in a programming exam"
Then concider you fail the exam.

This will get you started: Cpp-Programming-Tutorial/33-CPP-Classes-Object[^]
It would also be a good thing to use private members of the class, see: Public, Protected and Private Inheritance in C++ Programming[^]
   
Comments
merano99 19-Jan-21 11:55am
   
The linked tutorial is really bad.


"conio.h is a C header file used mostly by MS-DOS compilers to provide console input/output.[1] It is not part of the C standard library or ISO C, nor is it defined by POSIX."
https://en.wikipedia.org/wiki/Conio.h
Better never use it - neither for C nor for C ++

Why declare Id and Age as int?
Is it usefull to reach neagtiv?

Why declare name as "char Name[25]"?
Would expect string here.
RickZeeland 19-Jan-21 12:18pm
   
Thanks for the warning, could have known by the name "TutorialDost" that the site was DOS oriented 😊
We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]
   
Break down the Problem in some small Steps, like OriginalGriff suggested.

1. Declare a Class with needed Membervariables and Methods
C++
class employee { ... }

2. Write a main with required output; perhaps like this:
C++
int main()
{
  string  first("Pelin"), last("Yilmaz");
  unsigned long salary = 3000;
  class employee ma1(first, last, salary);
  cout << "Name:" << ma1.NameGet() << ", Salary:" << 
       ma1.SalGet() << ", Increase:" << ma1.increase();
  return 0;
}

3. Complete the code

4. Check if it compiles and the result ist ok.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900