Question 1: Prime numbers

Definition: A prime number is an integer number that is divisable by 1 and itself only. 2 is the first known prime number, then 3, then 5, then 7, then 11 and so on.

Write a Fortran program that uses subroutines and functions in order to print the first n prime numbers on the output, where n is an integer value has to be entered by the user.

The output has to be formatted as five prime numbers per line. For example, if n = 11, then the output of the program should be:

2               3               5               7               11
13              17              19              23              29

Hint: Write a function called Isprime. This function takes an integer and return a boolean depending on the primarity of this integer.

Question 2: Household Income survey

Question 2: Household Income survey

Concepts such as arrays and subroutines should be used for this question.

The result of a survey of households in Montreal are available for public scrutiny. Each record contains data for one household, including a four digit integer identification number, the annual income for the household, and the number of household members. Write a Fortran program to read the survey results into three arrays. The data terminates with the data line 0 0 0, at this point the program performs the following analysis:

    1. Count the number of household included in the survey and print a three-column table displaying the data in reverse order (excluding the last data line). Assume that no more 50 household were surveyed).

    2. Calculate the average household income and list the identification number and income of those households that exceed the average.

    3. Determine the percentage of households that have incomes below the poverty level. Computer the poverty level income using the formula:

      where m is the number of members of each household. This informations shows that the poverty level depends on the number of family members, m, and that the poverty level income increases as m gets larger.

Test your program on the following data:

Identification Number           Annual Income           Household Members
---------------------           -------------           -----------------
       1041                        12,180                       4
       1062                        13,240                       3
       1327                        19,800                       2
       1483                        22,458                       8
       1900                        17,000                       2
       2112                        18,125                       7
       2345                        15,623                       2
       3210                         3,200                       6
       3600                         6,500                       5
       3601                        11,970                       2
       4725                         8,900                       3
       6217                        10,000                       2
       9280                         6,200                       1
       0                            0                           0

Instructor Code - CS208
Thu Feb 19 10:33:48 EST 1998