Skip to main content
Engineering LibreTexts

10.10: Exercises

  • Page ID
    54294
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    Below are some quiz questions and project suggestions based on this chapter.

    Quiz Questions

    Below are some quiz questions.

    1. What is the format specifier for each of the following:
      1. integer values
      2. real values
      3. logical values
      4. horizontal spacing (i.e., spaces)
      5. a new line
      6. characters/strings
    2. Describe the output of the following code fragment (1 pts each):
      Note, show blanks with an _ (underscore) character.
      write (*,'(a5)') "Hello World"
      write (*,'(a)') "Hello World"
      
    3. Describe the output of the following code fragment (3 pts):
      Note, show blanks with an _ (underscore) character.
      integer :: number = 5
      write (*,'(i5.3)') number
      
    4. What is the write statement and format specifier to output the integer variable num1 which contains a value between 0 and 999 (right justified, no leading zero's, no additional spaces).
    5. What is the write statement and format specifier to output the real value of pi which has been initialized to 3.14159 (right justified, no additional spaces)?
    6. What is the single write statement and format specifier to output "Programming" and "Is Fun!" on two different lines?
    7. What is the single write statement and format specifier to output "Enter Number:" and leave the cursor on the current line?

    Suggested Projects

    Below are some suggested projects.

    1. Type in the date formatting program example, compile, and execute the program. Test the program on a series of different input values and verify that the output is correct for those input values.
    2. Update the date formatting program to perform complete error checking on the date entered. That is, the program should check for appropriate values for month (between 1 and 12), check for appropriate values for date (between 1 and 31), including checking for a valid date for the specific month, and ensure that the value for year is between 1970 and 3000 (inclusive). For example, April 31 is not a valid date. Additionally, the program should check for a leap year to see if February has 28 or 29 days for that year. Test the program on a series of different input values and verify that the output is correct for those input values.
    3. Write a Fortran program that displays an amortization schedule. The program should read the loan amount, annual interest rate, and the loan term in months (from a single line).
      The formula for calculating the monthly payment is:\[ \textit{payment} = \textit{amount} \cdot \left( \textit{irate} \cdot \frac{ \left(1 + \textit{irate} \right)^{\textit{term}} }{ \left( \left( 1 + \textit{irate} \right)^{\textit{term}} -1 \right) } \right) \nonumber \]Note, the annual interest rate, irate, in the formula must be converted to a monthly rate (divided by 12) and then divided by 100 (to convert from percentage). During the time period, term, some of each monthly payment will be used to pay the interest and some will be used to reduce the outstanding balance. The monthly interest amount can be calculated by multiplying the monthly interest rate times outstanding balance. The amounts must be lined up with only two digits for cents. The payment number must display three digits, including leading zeros if necessary. Test the program on a series of different input values and verify that the output is correct for those input values.
      Output will consist of appropriate headings and aligned and formatted columns for payment number, monthly payment, principal paid, interest paid, and outstanding balance. A sum will appear at the bottom of each column.
      Loan amounts shall not exceed $250,000 and the maximum loan term shall not exceed 360 months. Be sure to follow the requirement that the three input variables will be formatted on a single line.
    4. Write a Fortran program that calculates and displays compounded interest. The program should read the initial principal amount, interest rate percentage, and the term (number of years). The program should display a summary of the input and the yearly compounded interest. Refer to the example output for formatting.
      The formula for compounding interest is:\[\textit{value} = \textit{principal}\left( 1 + \textit{interest} \right)^{\textit{year}} \nonumber \]Note, the interest rate percentage read from the user must be converted to a number (i.e., divided by 100). The output must be formatted in a manner similar to the example output. This includes ensuring that the dollar amounts are displayed with the appropriate two decimal points. Test the program on a series of different input values and verify that the output is correct for those input values.

    This page titled 10.10: Exercises is shared under a CC BY-NC-SA 3.0 license and was authored, remixed, and/or curated by Ed Jorgensen via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.

    • Was this article helpful?