Create a program named friendlist that declares an array of


1 a. Create a program named FriendList that declares an array of eight Friend objects and prompts the user to enter data about the friends. Display the Friend objects in alphabetical order by first name. The Friend class includes auto-implemented properties for the Friend's name, phone number, and three integers that together represent the Friend's birthday-month, day, and year.

b. Create a FriendBirthday program that modifies the FriendList program created in Exercise 9a so that after the list of Friend objects is displayed, the program prompts the user for a specific Friend's name and the program returns the Friend's phone number and birthday. Display an appropriate message if the friend requested by the user is not found.

c. Create a program named AllFriendsInSameMonth that modifies the program in Exercise 9b so that after the requested Friend's birthday is displayed, the program also displays a list of every Friend who has a birthday in the same month.

2. a. Write a program named demojobs for Harold's Home Services. The program should instantiate several Job objects and demonstrate their methods. The Job class contains four data fields-description (for example, "wash windows"), time in hours to complete (for example, 3.5), per-hour rate charged (for example, $25.00), and total fee (hourly rate times hours). Include properties to get and set each field except the total fee-that field will be read-only, and its value is calculated each time either the hourly fee or the number of hours is set. Overload the + operator so that two Jobs can be added. The sum of two Jobs is a new Job containing the descriptions of both original Jobs (joined by "and"), the sum of the time in hours for the original Jobs, and the average of the hourly rate for the original Jobs.

b. Harold has realized that his method for computing the fee for combined jobs is not fair. For example, consider the following:
- His fee for painting a house is $100 per hour. If a job takes 10 hours, he earns $1000.
- His fee for dog walking is $10 per hour. If a job takes 1 hour, he earns $10.
- If he combines the two jobs and works a total of 11 hours, he earns only the average rate of $55 per hour, or $605.
Devise an improved, weighted method for calculating Harold's fees for combined Jobs and include it in the overloaded operator+() method. Write a program named DemoJobs2 that demonstrates all the methods in the class work correctly.

3. a. Write a FractionDemo program that instantiates several Fraction objects and demonstrates that their methods work correctly.

Create a Fraction class with fields that hold a whole number, a numerator, and a denominator.

In addition:
- Create properties for each field. The setaccessor for the denominator should not allow a 0 value; the value defaults to 1.
- Add three constructors. One takes three parameters for a whole number, numerator, and denominator. Another accepts two parameters for the numerator and denominator; when this constructor is used, the whole number value is 0. The last constructor is parameterless; it sets the whole number and numerator to 0 and the denominator to 1. (After construction, Fractions do not have to be reduced to proper form. For example, even though 3/9 could be reduced to 1/3, your constructors do not have to perform this task.)
- Add a Reduce() method that reduces a Fraction if it is in improper form. For example, 2/4 should be reduced to 1/2.
- Add an operator+() method that adds two Fractions. To add two fractions, first eliminate any whole number part of the value. For example, 2 1/4 becomes 9/4 and 1 3/5 becomes 8/5. Find a common denominator and convert the fractions to it. For example, when adding 9/4 and 8/5, you can convert them to 45/20 and 32/20. Then you can add the numerators, giving 77/20. Finally, call the Reduce() method to reduce the result, restoring any whole number value so the fractional part of the number is less than 1. For example, 77/20 becomes 3 17/20.

- Include a function that returns a string that contains a Fraction in the usual display format-the whole number, a space, the numerator, a slash (/), and a denominator. When the whole number is 0, just the Fraction part of the value should be displayed (for example, 1/2 instead of 0 1/2). If the numerator is 0, just the whole number should be displayed (for example, 2 instead of 2 0/3).

b. Add an operator*() method to the Fraction class created in Exercise 11a so that it correctly multiplies two Fractions. The result should be in proper, reduced format. Demonstrate that the method works correctly in a program named FractionDemo2.

c. Write a program named FractionDemo3 that includes an array of four Fractions. Prompt the user for values for each. Display every possible combination of addition results and every possible combination of multiplication results for each Fraction pair (that is, each type will have 16 results).

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Create a program named friendlist that declares an array of
Reference No:- TGS01661934

Now Priced at $35 (50% Discount)

Recommended (92%)

Rated (4.4/5)