Skip to main content
Engineering LibreTexts

16.7: Exercises

  • Page ID
    54372
  • \( \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. An item in a derived data type is called?
    2. How are components of a derived data type accessed?
    3. Define a derived data type, circle, to store information about a circle. Must include a circle name (max 20 characters), size (radius – a real value) and the position in 3-dimensional space (\(x\), \(y\), and \(z\) \(\rightarrow\) all integer values).
    4. Write the declaration necessary to declare two variables named ring1 and ring2 of type circle (from previous question).
    5. Define a user-defined type, planet, to store information for a planet. Include a name (15 characters), radius (real value), area (real value), and volume (real value). Additionally, write the declaration necessary to declare two variables named earth and mars of type planet.
    6. Define a user-defined type named date for processing dates consisting of a month name (10 characters), month (integer), date of month (integer), and year (integer).
    7. Based on the previous question
      1. Write the statements to declare a variable named today and set it to 12/25/2013.
      2. Write the statements to declare a variable named newyear and set it to January 1, 2011.

    Suggested Projects

    Below are some suggested projects.

    1. Type in the time summation program, compile and execute the program. Test on several sets of input including the example in the explanation.
    2. Write a Fortran program to read and display information about a set of planetary bodies. The program should read the information from a file, allow the user to select a display option, and call the appropriate routine to display that information.
      The main program should call a series of subroutines as follows:
      • Subroutine readPlanets() to prompt for a file name of the planets file, open the file (including error checking), and read the file into an array. Three errors are allowed, but if a fourth error is made, the routine should terminate the program.
      • Subroutine calcPlanetArea() to calculate the planet area based on the diameters.
      • Function getUserOption() to display a list of options, read the selection option.
      • Subroutine displayPlanetMinMax() to display the minimum and maximum based on an option as follows:
        • Option (1) \(\rightarrow\) Smallest and Largest Planets (based on area)
        • Option (2) \(\rightarrow\) Coldest and Hottest Planets (based on average temperature)
        • Option (3) \(\rightarrow\) Planets with Shortest and Longest Days (based on day length)
      • Subroutine printPlanetsSummary() to display the planet name, distance from sun, and planet size.
      The output should be formatted as appropriate. Test on several sets of input values and verify that the output is correct for the given input values.
    3. Modify the planet program (from previous question) to sort the planets based on the radius. Test on several sets of input values and verify that the output is correct for the given input values.
    4. Type in the time class scores program, compile and execute the program. Test on several sets of input values.
    5. Modify the class scores program to assign grades based on the following scale:
      F D C- C C+ B- B B+ A- A A+
      \(0-59\) \(60-70\) \(70-72\) \(73-76\) \(77-79\) \(80-82\) \(83-86\) \(87-89\) \(90-92\) \(93-96\) \(97-100\)
      Test on several sets of input values and verify that the output is correct for the given input.
    6. Modify the class scores program to read the name and score file. The program should include prompting for a file, opening the file, and reading the file contents into the class array. In order to complete this exercise, create a file containing some random names and scores. Test on several sets of input values.

    This page titled 16.7: 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?