This part comprises ten questions. Each question is worth 10 marks. All questions in part 1 will need to be completed.
when solving the problems in this section, you must follow the application programming interface (API) expected in each problem. You should implement all the attributes and operations mentioned in the API.
Note that there is no main method in the APIs. That is, you should not perform any data processing within the main method. You should rather use the main method to test other methods, prompt the user for some inputs, and display the results returned by your methods.
Create a class named AddressBook that has the following field names:
firstName, middleName, lastName, homeAddress, businessPhone, homePhone, cellphone, skypeId, facebookId, and personalWebSite.
Use appropriate data types to store the values for these fields in AddressBook objects.
Create appropriate get and set methods to retrieve and assign values to these names. For example, getMiddleName(viveAddressBook) should return the middle name of the person Vive. Similarly, vive.setPersonalWebsite(url) should set the personal website of the person Vive to the specified URL object.
Using the get and set methods, create a comparison method compareNames(name1, name2) that compares the first, middle, and last names of strings name1 and name2. Assume that name1 and name2 follow the following format: “FirstName M. LastName”.
Test your program for correct, partially correct (e.g., name string without the middleName), and incorrect inputs (e.g., phone number containing special characters).
A group of AU friends decide to run the Banff, Alberta, Marathon. Their names, times (marathon completion time in minutes), and number of years participated are given below:
1
|
Elena Brandon
|
341
|
1
|
2
|
Thomas Molson
|
273
|
2
|
3
|
Hamilton Winn
|
278
|
5
|
4
|
Suzie Sarandin
|
329
|
7
|
5
|
Philip Winne
|
445
|
9
|
6
|
Alex Trebok
|
275
|
3
|
7
|
Emma Pivoto
|
275
|
4
|
8
|
John Lenthen
|
243
|
1
|
9
|
James Lean
|
334
|
1
|
10
|
Jane Ostin
|
412
|
1
|
11
|
Emily Car
|
393
|
4
|
12
|
Daniel Hamshire
|
299
|
4
|
13
|
Neda Bazdar
|
343
|
3
|
14
|
Aaron Smith
|
317
|
6
|
15
|
Kate Hen
|
265
|
8
|
Extend the AddressBook class from Problem 1 to store the additional data. Now, write a method to find the fastest runner. Print the name, address, and his/her time (in minutes) on three separate lines.
Find the second fastest runner. Print the name, address, his/her time (in minutes), and the difference in time with the fastest runner.
Compute the average time of completion taken by these runners.
Finally, print the name and number of years participated for each runner if the runner’s time of completion is equal to or better than the average time of completion.
Solve the following problem using a program: Suppose you save $100 each month into a savings account with an annual interest rate of 5%. Thus, the monthly interest rate is 0.05/12 = 0.00417.
Write a program that randomly generates monthly savings amounts for the 15 runners in Problem 4. Each monthly saving should be in the range of $100 to $800. Extend the AddressBook class to store the monthly savings generated by the random number generator.
Then, display the final account value for each of the 15 runners.
Google Inc. is looking to recruit three of the Boston runners. The criteria for selection are as follows:
Average final marks in bachelor’s degree (store up to 2 decimal places). The fifteen candidates have the following grades: 82.30%, 85.10%, 77.77%, 69.93%, 93.03%, 88.61%, 55.99%, 87.49%, 88.00%, 91.20%, 66.79%, 76.65%, 55.89%, 90.01%, and 87.9%.
Ability to communicate as one of the three values – “excellent”, “average”, and “poor”. The fifteen candidates have the following ability to communicate, respectively: poor, poor, average, average, average, poor, excellent, excellent, excellent, average, excellent, average, excellent, excellent, poor.
Innovation as one of the two values – “brilliant” and “average” (store as a Boolean; brilliant = true and average = false). The fifteen candidates have the following innovative abilities: brilliant, average, average, average, brilliant, brilliant, average, brilliant, average, brilliant, average, brilliant, brilliant, average, average.
Ability to regulate one’s own skill as a probability value between 0 and 1.0 – 1.0 implies excellent regulatory capabilities and 0.0 implies no skills to regulate (store as a double). The fifteen candidates have the following regulatory abilities: 0.5, 1.0, 0.8, 0.0, 1.0, 0.7, 0.8, 0,9, 0.5, 0.6, 0.3, 0.2, 0.5, 0.3, 0.8.
Store these values for the fifteen candidates in an extended AddressBook class. In general, Google will not consider a candidate with average marks of less than 85%. Google will consider a candidate with average marks of less than 85% only if the candidate at least has 0.5 regulatory abilities and at least ‘average’ ability to communicate. Google will only consider a candidate with poor communication ability if the candidate has a ‘brilliant’ innovation capability. Write a program that will help Google to programmatically determine eligibility of the fifteen candidates for these positions, and print the output on the console.