Posts

12. Create a four-function calculator for fractions. The user should type the first fraction, an operator, and a second fraction. The program should then display the result and ask whether the user wants to continue.

11. Create a three-function calculator for old-style English currency. The calculator should allow the user to add or subtract two money amounts, or to multiply a money amount by a floating-point number.

10. Program where you tell the final amount and it figures out how many years it will take, at a fixed rate of interest compounded yearly, to reach this amount.

8. Program that repeatedly asks the user to enter two money amounts expressed in old-style British currency: pounds, shillings, and pence. The program should then add the two amounts and display the answer, again in pounds, shillings, and pence. Use a do loop that asks the user whether the program should be terminated.

7. Program that calculates how much money you’ll end up with if you invest an amount of money at a fixed interest rate, compounded yearly. Have the user furnish the initial amount, the number of years, and the yearly interest rate in percent.

6. Modify the FACTOR program in this chapter so that it repeatedly asks for a number and calculates its factorial, until the user enters 0, at which point it terminates.

5. Use for loops to construct a program that displays a pyramid of Xs on the screen.

4. Program should ask the user to enter a number, an operator, and another number. It should then carry out the specified arithmetical operation: adding, subtracting, multiplying, or dividing the two numbers. Finally, display the result.

3. Program that should allow the user to type up to six digits, and then display the resulting number as a type long integer.

2. Temperature-conversion program that gives the user the option of converting Fahrenheit to Celsius or Celsius to Fahrenheit. Then carry out the conversion.

7. Program that allows the user to enter a floating-point number representing degrees Celsius, and then displays the corresponding degrees Fahrenheit.

1. Program that allows the user to enter the number and then generates the table, formatting it into 10 columns and 20 lines.

12. Write the inverse of Exercise 10, so that the user enters an amount in Great Britain’s new decimal-pounds notation (pounds and pence), and the program converts it to the old pounds-shillings-pence notation.

11. Left-justify text output using the manipulator setiosflags(ios::left). Use this manipulator, along with setw(), to help generate the following output.

10. Program to convert the old pounds-shillings-pence format to decimal pounds.

9. Program that encourages the user to enter two fractions, and then displays their sum in fractional form.

8. Rewrite the WIDTH program so that the characters on each line between the location name and the population number are filled in with periods instead of spaces.

6. Program that allows the user to enter an amount in dollars, and the displays this value converted to other monetary units.

5. Program that allows the user to enter a letter, and then displays either zero or nonzero, depending on whether a lowercase or uppercase letter was entered.

4. Program that displays your favorite poem. Use an appropriate escape sequence for the line breaks.