Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Name pania Masadape CS265 Exam Fall 2018 1. (1S pts) Using your declaration(s),

ID: 3755393 • Letter: N

Question

Name pania Masadape CS265 Exam Fall 2018 1. (1S pts) Using your declaration(s), write a function, RalseCommission, including its header, as described below Receives: A double array of pCommissions, an integer number for the array size. Algorithm: The array will be updated as following: all commissions in the array that are less than 1000 will be increased by 3 percent, otherwise the commissions will be increased by 5 percent. is updated. 0 pts) what are the three major features/principals/pillars of OOP that we discussed in c t is the difference between function overloading and function overriding? Please also ccessible level of keywords private, protected and public within package and class.

Explanation / Answer

Q1) From what i understand a function has to be created in which the elements of given array if they are less than 1000 has to be increased by 3% otherwise 5% and updated array to be returned.

int array(double pcommissions[],int size)

{

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

{

if(pcommissions[i]<1000)

pcommissions[i]=pcommisions[i]+(3/100)*pcommissions[i];

else

pcommissions[i]=pcommissions[i]+(5/100)*pcommissions[i];

}

printf("%d" , pcommissions[i]); //return can be used too.

} //this code has not been compiled

Q2) Three major principals of OOP:-

1)Inheritance:-It can be defined as the relationship between different classes.The relationship is that of a parent and child.The child uses the methods defined in parent class.Now, one parent can have many children so many children can inherit fromm same parent.

2)Encapsulation:- It basically means hiding some part.It hides the implementation details and only exposes the operations.It protects the internal state of object and the classes can be accessed by methods like get and set.This makes the class flexible and easy to maintain.

3) Polymorphism- It basically means false form.It means having single form but different implementation ways.It basically simplifies maintaining applications making them more extendable.

ii)Difference between overloading and overriding.

The basic difference is overloading occurs when two or more methods in one class have the same method name but different parameters and overriding means means having two methods with the same method name and parameters.

Overloading cannot use polymorphism whereas overriding can.

Overriding is a run-time concept while overloading is a compile-time concept.

iii) Private-Access is limited to the containing type.

Protected-Access is limited to containing class or types derived from containing class

Public-Access is not restricted.