

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


CS 101 Unpledged
Page 1 of 2 Spring 1997
Please perform the following activities. Note that although you are allowed to talk with others, your work must be your own.
To practice creating programs that do interactive input and output, and to make sure that you understand how to write simple programs that compute useful things.
The Treasury Department through the Bureau of Public Debt sells Treasury bills or as they are commonly called T-bills. The T-bills are investment notes backed by the United States govern- ment. The typical T-bill is a $10,000 note that is redeemable for that amount after some govern- ment-specified number of days. A T-bill is sold at a discount where the difference between the face value of a redeemed note and its buying price is the interest paid on the investment. For example, the Bureau sold notes this month at a price of $9,872.90 with a term of 91 days that can be redeemed for $10,000. We are interested in knowing the annual percentage rate of such an investment. The annual percentage rate can be computed in the following manner.
Step 1. Let RedeemedValue be the value of note upon redemption. For the example given above, this amount is $10,000. Step 2. Let PurchasePrice be the cost of the note. For the above example, this amount is $9,872.90. Step 3. Let Term be the number of days for the note to mature. For the above example, this value is 91. Step 4. Compute the interest rate for the term of the note. This rate is given by the expression ( RedeemedValue ÷ PurchasePrice ) - 1. For the above example, the value of this expression is approximately 0.01287. Step 5. Compute the number of terms per year. This number is given by the expression by 365 ÷ Term. For the above example, the value of the expression is approximately 4.01098. Step 6. Compute the annual interest rate per year. This value is given by the product of the interest rate for the term of the note and the number of terms per year. For the above example, the annual interest rate is approximately 0.05163. Step 7. Compute the annual percentage rate. This value is the given by the product of the annual interest rate and 100. For the above example, the annual interest rate is approx- imately 5.16%.
Your task is to write a program that individually prompts its user for three values:
CS 101 Unpledged
Page 2 of 2 Spring 1997
The program then computes and displays the annual percentage rate corresponding for the associ- ated T-bill. Figure 1 illustrates the type of input and output your program should produce.
Figure 1: Sample input/output behavior of program tbill.cpp.