Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Read the given case study and answer the following questions (Question 1-Question 5) You are appointed by a local consulting company for a project

image text in transcribedimage text in transcribed

Read the given case study and answer the following questions (Question 1-Question 5) You are appointed by a local consulting company for a project to design and implement an employee's records system. The work is to develop a program that calculates each employee's total salary based on the Grade level as shown in the figure below. Employee_Grade Bonus Base_Salary 5 80,000 30% 4 70000 25% 3 60000 20% 2 50000 15% 1 40000 10% The formula to evaluate total salary is: Total_salary = Base_salary + (bonus*base_salary)/100. You are asked to write snippets (small pieces of reusable code) based on the questions that you might consolidate and use in the final program. There are 5 questions based on the case study. Answer all the given questions based on the given case study. Make necessary assumptions If required. Question 5 10 marks The company expects to implement concept of Object-oriented programming concepts (OOPs) a. Write the snippet to define a class 'Employee' with required attributes/states and methods/behavior to calculate the salary. b. Write the constructor to initialize the attributes such as employee name, employee id and grade. c. Create an instance/object of class 'Employee' passed with employee name, employee id and grade. d. Show how one can implement polymorphism and encapsulation in the given program. This lab was designed to reinforce programming concepts from this lab, you will practice: Declaring and initializing arrays. Comparing input to array elements. Preventing array out-of-bounds errors. The follow-up questions and activities will also give you practice: Initializing array sizes during program execution. Description. Write a static method named longer that accepts two arrays of strings al and a2 as parameters and returns a new array a3 such that each element of a3 at each index stores whichever string has greater length (more characters) between the elements at that same index in arrays al and a2. If there is a tie, take the element from al. For example, if al and a2 store the following elements: = String[] al {"star", "pie", "jelly bean", "car"}; String[] a2 = {"cookie", "fig", "banana", "soda"}; Then your method should return the new array {"cookie", "pie", "jelly bean", "soda"}. If the arrays al and a2 are not the same length, the result returned by your method should have as many elements as the larger of the two arrays. If a given index i is in bounds of al but not a2 (or vice versa), there are not two elements to compare, so your result array's element at index i should store the value "oops". For example, if al and a2 store the following elements: = String[] al {"Splinter", "Leo", "April", "Don", "Raph"}; String[] a2 = {"Krang", "Shredder", "Bebop"}; Then your method should return the new array {"Splinter", "oops", "oops" }. "Shredder", "April", Do not modify the elements of al or a2. Do not make any assumptions about the length of al or a2 or the length of the strings. You may assume that neither array is null and no element of either array is null.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Computer Networking A Top-Down Approach

Authors: James Kurose, Keith Ross

7th edition

978-0133594140

More Books

Students also viewed these Computer Network questions