Exercise P10.2. Write a recursive function void reverse() that reverses a sentence. For example: Sentence greeting = new Sentence("Hello!"); greeting.reverse(); cout << greeting.get_text()<<endl; prints the string “olleh”. Implement a recursive solution by removing the first character, reversing a sentence consisting of the remaining text, and combining the two.

Exercise P14.1. Finish the implementation of the class Fraction by overloading the remaining arithmetic operation. Exercise P14.3. Determine which function in class Fraction are candidates for inlining. Rewrite the class to inline those you identify, and identify, and test the resulting application.

Exercise P8.6.Write a base class Worker and derived classes HourlyWorker and SalariedWorker. Every worker has a name and a salary rate. Write a virtual function compute_pay(int hours) that computes the weekly pay for every worker. An hourly worker gets paid the hourly wage for the actual number of hours worked, if hours is at most 40. If the hourly worker worked more than 40 hours, the excess is paid at time and a half. The salaried worker gets paid the hourly wage for 40 hours, no matter what the actual number of hours is.

Exercise P9.1.Write a program that asks the user for a profile name and displays the number of characters, words, and lines in that file. Then have the program ask for the name of the next file. When the user enters a file that doesn’t exist (such as the empty string), the program should exit




 

 

    • 10 years ago
    A+ Work
    NOT RATED

    Purchase the answer to view it

    blurred-text
    • attachment
      qayr11.zip