Program to demonstrate basic concept of Class, Methods and Objects:
Problem Statement :
Create a class employee that includes three pieces of a information as instance variables- first name, and last name and a monthly salary. Your class should have a constructor that initializes the 3 instance variable. Provide a set and to get method for each instancevariables. If the monthly salary is not positive, then set it to zero. Write a test application named Employee Test that demonstrates class Employee' capabilitie. Create a 2 Employee objects and display the each object yearly salary. Then each Employee a 10% raise and display the each Employee's yearly salary again.
Introduction
·
Object
- Objects have states and behaviors.
· Class
- A class can be defined as a template/blueprint that describes the behavior/state that the object of its type
supports.
· Methods - A method is basically a behavior. A class can contain many methods.It is in methods where the logics are written, data is manipulated and all the actions are executed.
out put
enter detsils of two employee
enter first name
ajay
enter lasst name
patil
enter monthly salary
5000
enter first name
vijay
enter lasst name
patil
enter monthly salary
8000
******detail information of an employee****
first nmae:ajay
last name:patil
mont salary:5000.0
yerly salary:60000.0
salary after raise of 10%:6000.0
final salary:66000.0
first nmae:vijay
last name:patil
mont salary:8000.0
yerly salary:96000.0
salary after raise of 10%:9600.0
final salary:105600.0
This site is really helpful for me. Thank you 🙂
ReplyDeletegood
ReplyDelete