Problem 35
The factorial of a nonnegative integer \(n\) is written \(n !\) (pronounced " \(n\) factorial") and is defined as follows: \(n !=n \cdot(n 1) \cdot(n 2) \cdot \ldots \cdot 1 \text { (for values of } n \text { greater than to } 1)\) and \(n !=1\) (for \(n=0\) or \(n=1\) ). For example, \(5 !=5 \cdot 4 \cdot 3 \cdot 2 \cdot 1,\) which is \(120 .\) Use while statements in each of the following: a. Write a program that reads a nonnegative integer and computes and prints its factorial. b. Write a program that estimates the value of the mathematical constant \(e\) by using the formula: \(e=1+\frac{1}{1 !}+\frac{1}{2 !}+\frac{1}{3 !}+\dots\) Prompt the user for the desired accuracy of \(e\) (i.e., the number of terms in the summation). c. Write a program that computes the value of \(e^{x}\) by using the formula \\[ e^{x}=1+\frac{x}{1 !}+\frac{x^{2}}{2 !}+\frac{x^{3}}{3 !}+\ldots \\] Prompt the user for the desired accuracy of e (i.e., the number of terms in the summation).
Problem 36
[Note: This exercise corresponds to Section 4.13 , a portion of our software engineering case study.] Describe in 200 words or fewer what an automobile is and does. List the nouns and verbs separately. In the text, we stated that each noun might correspond to an object that will need to be built to implement a system, in this case a car. Pick five of the objects you listed, and, for each, list several attributes and several behaviors. Describe briefly how these objects interact with one another and other objects in your description. You have just performed several of the key steps in a typical object-oriented design.