Select Year: 2020 Select a Trimester: 2 Subject: ISY2006/ISY211 Objected Oriented Programming Length of Exam: 2.5 hours Weight: 40% Total Marks: 40% Section Question Type Number of Questions Number of...

1 answer below »
Select Year: 2020 Select a Trimester: 2 Subject: ISY2006/ISY211 Objected Oriented Programming Length of Exam: 2.5 hours Weight: 40% Total Marks: 40% Section Question Type Number of Questions Number of Marks per question TOTAL MARKS A Essay questions. 5 3 Marks each 15 Marks B Supplementing the missing piece of code. 5 3 Marks each 15 Marks C Writing own code for a given problem. 2 5 Marks each 10 Marks TOTAL / 40 2 Section A 15 Marks Answer all the questions in this section. Explain your answer and give appropriate example. Each question is worth 3 marks. 1. Indicate whether each of the following C# programming language identifiers is legal or illegal. If it is legal, indicate whether it is a conventional identifier for a class. Explain your answer. a. electricBill g. Ay56we b. ElectricBill h. Theater_Tickets c. Electric bill i. 212AreaCode d. Static j. heightInCentimeters e. void k. Zip23891 f. #ssn l. Void 2. How is a named constant different from a variable? How would you create a named constant? Show an example. 3. Creating an object requires two steps that are shown in the example below: Employee myAssistant; myAssistant = new Employee(); What do these statements accomplish? 4. For a method that accepts a parameter, what are the components of the parameter definition that must be included in the method declaration? Show an example of a method declaration with a parameter. 5. Show an example of a class definition that creates a subclass of an existing Employee class, and adds a private double field called commissionRate. What is the total set of fields that an instance of the new class contains? 3 Section B 15 Marks Answer all the questions in this section. Each question is worth 3 marks. Read what is required from each question carefully and answer all parts of the question. 1. Australian car rental centre Kayak charges $30 per day plus 15 cents per mile. Write a C# program that prompts the user for and accepts a number of days and miles driven and call method named CarRental to calculate and then display the total rental fee. (3 marks) 2. Complete the segment of C# code that allows a doctor’s staff to enter data about patients and saves the data to a file called Patients.txt. The output should be in the following format: p#, PATIENT_NAME, BALANCE. Create a Patient class that contains fields for ID number, name, and current balance owed to the doctor’s office. (3 marks) 3. Create a program named FindSquareRoot that finds the square root of a user’s input value. The Math class contains a static method named Sqrt() that accepts a double and returns the parameter’s square root. If the user’s entry cannot be converted to a double, display an appropriate message, and set the square root value to 0. Otherwise, test the input number’s value. If it is negative, throw a new Application Exception to which you pass the message “Number can’t be negative.” and again set sqrt to 0. If the input value is a double and not negative, pass it to the Math.Sqrt() method, and display the returned value. (3 marks) 4 4. Complete the following C# code to find the sum of all elements of an array. (3 marks) 5. Write an example method that overrides the + operator to create a new book whose title is a concatenation of the titles of two books. For example, if the first book's title is "The Adventures of Tom Sawyer" and the second book's title is "The Adventures of Huckleberry Finn", the concatenated title will be "The Adventures of Tom Sawyer and The Adventures of Huckleberry Finn". Assume the book class is defined as: (3 marks) 5 Section C 10 Marks Answer all the questions in this section. Each question is worth (5) marks. Read what is required from each question carefully and answer all parts of the question. 1. Create an application named PhotoStudio that instantiates objects of three classes named Photo, MattedPhoto, and FramedPhoto and that demonstrates all their methods. Create a class named Photo that includes fields for width and height in inches and properties for each field. Include a protected field for price and protected method that set price to $3.99 for an 8-inch by 10-inch photo, $5.99 for a 10-inch by 12-inch photo, and $9.99 for any other size. The price field requires a get accessor but no set accessor. Also include a ToString() method that returns a string constructed from the return value of the object’s GetType() method and the values of the fields. (5 marks) 2. Extend the Photo class (from the question 1) to two more specialized classes: MattedPhoto and FramedPhoto. The MattedPhoto class includes a string field to hold a color, and the FramedPhoto class includes two string fields that hold the frame’s material (such assilver) and style (such as modern). The price for a MattedPhoto increases by $10 over its base cost, and the price for a FramedPhoto increases by $25 over its base cost. Each subclass should include a ToString() method that overrides the parent class
Answered Same DayOct 09, 2021

Answer To: Select Year: 2020 Select a Trimester: 2 Subject: ISY2006/ISY211 Objected Oriented Programming Length...

Aditya answered on Oct 26 2021
147 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here