Reference no: EM133356285
Object oriented programming
Section A
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.
a.electricBill
|
g.Ay56we
|
b.ElectricBill
|
h.Ticket
|
c.Electricbill
|
i. 212AreaCode
|
d.Static
|
j. heightInCentimeters
|
e.void
|
k.Zip23891
|
f. #ssn
|
l. Void
|
How is a named constant different from a variable? How would you create a named constant? Show an example.
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.
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?
Section B
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.
Write a program named Admission for a college's admissions office. The user enters a numeric high school grade point average (for example, 3.2) and an admission test score. Display the message Accept if the student meets either of the following requirements:
A grade point average of 3.0 or higher, and an admission test score of at least 60
A grade point average of less than 3.0, and an admission test score of at least 80
If the student does not meet either of the qualification criteria, display Reject.
Complete the following C# code to find the sum of all elements of an array.
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:
Section C
Read what is required from each question carefully and answer all parts of the question.
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.
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 as silver) 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 version.