Introduction to Scientific & Engineering Computing

F Programing Language BIL 106 E

The following program contains a number of errors. Identify them and submit a corrected
version up to the return date.

Program example_week_2
! This program contains several errors
real :: Var-1, Var 2, Var_3, Var4
print "please type four numbers separated by commas"
print "such as 1,2,3,4"
! Now print the3 numbers to check that they were
! Input correctly
print * "The numbers you typed were
print *,Var-1, Var 2, Var_3, Var4
print "you did the job – congratulations !"
End Program Example_of_week_2

 

Write program writing steps. 

 

Write properties of well-designed programs.

 

Write 5 different programming languages and their main features.

Write a program to add_two_integers and  finds the sum of any two integers supplied as input.

write a program to input a number x and print the values of x-1, x+2 and x^2 +x-2,

Write a program for a library in order to find the location of a book arranged with respect to the first letter of its title. Do not neglect the titles beginning with a number.

write a program which read a Fahrenheit temperature and then convert it to Celcius,

Write a program to calculates area of a rectangle

write a program that calculates µ value from following equation: µ = (m_a * m_b) / (m_a + m_b)

 

Write a program that determines how many times a human heart beats in a lifetime. Your program should work for any pulse-rate (e.g. 72 beats per minute) and any lifetime (e.g. 70 years). Assume 365.25 days in a year. Read pulse-rate and lifetime as input to the program.

 

Write a program, which calculates the sum of examination marks in a class having 75 students then gives the sum and the average of the examination marks as an output?

 

A construction company is going to on to build swimming pools which can be regarded as a figure consisting of one rectangle and one piece of a half-circle beside it planned for adults and children, respectively.

Prepare a computer program that calculates the total area of the swimming pool for the abovementioned type obtained each from the two different “function”  or “subprogram”s called “Area_Rectangle”and “Area_Circle”, respectively. Finally, print the geometrical lengths of the swimming pool and its total area.

 (Sample input as follows:

            Swimming pool           - rectangle      a = 40 m, b = 6 m

                                               - circle            r = b/2 = 3 m)

 

Write a subroutine which, when supplied with the coordinates of two points (x1,y1) and (x2,y2), calculates the distance of each point from the origin and the distance between the points. Note that the distance d1 of point 1 from the origin is given by the formula d1=sqrt(x1**2+y1**2)   while the distance d between the two points is given by d=sqrt((x2-x1)**2+(y2-y1)**2) Test your subroutine in a short program to check that it works correctly with several different sets of data.

 

Write a program to compute the volume of the shell of a hollow ball. The program should read the outside radius of the ball and the thickness of the shell. Hint: The volume of a sphere of radius r is 4pr3/3.

 

Write a program to find the sum of the successive even integers 2, 4, ..., 200.

 

Write a program that computes the net income for an hourly-worker for one week. The salary for an hour is 10$ up to 40 hours. If the worker works more than 40 hours per week than he/she is paid 50% more for each hour that is over 40. That is, any hour more than 40 is paid in 15$. Out of total income  10% is cut as tax and 15$ is cut for the retirement benefit. If the worker has more than 3 children, then for each child 10$ is cut from the worker total salary. That is, up t 3 children there is no penalty. But if the  number of children is more than 3 then there will be 10$ cut for each child.

 

Write a program to compute and print the real roots of a quadratic equation a*x**2+b*x+c=0
where a, b, and c are real coefficients. The formula used to calculate root is

Note that if the quantity within the square root sign (that is, the determinant) is negative, the root is complex. Also note that division by zero occurs if a = 0. Design your program so that it deals with these contingencies by printing error messages. In any case your program should print one of the messages below only:
There are two distinct roots:
X1 = … & x2 = …
There are two roots and they are equal to each other:
X1 = x2 = …
The roots are complex:
X1 =… & x2 = …

 

Using a case – structure prepare a computer program which shows your program on
Thursday and on Friday, as can be seen below :
Thursday
09.00 : 10.50 “Physics”
11.00 : 12.50 “Chemistry”  --- etc.
Then, carry out 2 sample runs for different days and hours.
Print the input values as well as the messages obtained as results.

 

Write a program which produces a table of sin x and cos x for angles x from 0° to 90° in steps of 15°.

 

Write a structure plan and program for the following problem: read 10 integers and write out how many of them are positive, negative or zero. Write the program with an IF or  a CASE construct.

Prepare a computer program which calculates and prints, the bottom surface area and the volume of a concrete cylinder block having the following initial values : radius r = 210 cm,  height h = 315 cm

When visitors come to dinner at his home in Istanbul, Mr. Unal always makes them middle-dark Turkish coffee. For four people, this requires the following ingredients:

            50 g of Turkish coffee

            40 g of sugar

            200 ml of water

Write a program that inputs the number of people coming to dinner and then prints the amount of each ingredient required.

Write a subroutine that will sort a set of numbers from the minimum one to the maximum one.
read the edges of a rectangle and write a subprogram which calculate area of rectangle
read the three edges of a triangle, write a subprogram which calculate area of triangle
Programming in F by T. M. R. Ellis, Ivor R. Philips, Page 194. Examp 8.1
Programming in F by T. M. R. Ellis, Ivor R. Philips, Page 180. Prob 7.1
Programming in F by T. M. R. Ellis, Ivor R. Philips, Page 260. Prob 9.1
Programming in F by T. M. R. Ellis, Ivor R. Philips, Page 187. Prob 7.2
Write a program that reads hourly temperature from a file and calculate the average of hourly temparature and print it.

Write a subroutine which, when supplied with the coordinates of two points (x1,y1) and (x2,y2), calculates the distance of each point from the origin and the distance between the points.

Store 12 five-digit numbers in an array. Purely by changing the output format, print the numbers as follows

a)      a single column of numbers;

b)      four row of three numbers;

c)      a single line of numbers.

 

Now modify (a new program) the program so that the format is unchanged, but altering the way in which a single write statement is used can produce the same three formats for the results.

Write a function which, when supplied with the coordinates of two points (x1, y1) and (x2, y2), calculates the distance between the points

Write and test a subroutine which prints a real number x, using a field width of 8, according to the following rules:

1-     If x=int(x) then the number should be displayed as an integer

2-     Otherwise, if it is possible, x should be printed in fixed point format to at least 3 significant figures.

3-     Otherwise x should be printed in floating point format to as many decimal places as will fit in the space available.