Homework 3, due September 25, 2008.
Posted: Thu Sep 18, 2008 2:23 pm
Reading: Chapter 3 from the course text.
Collaborative Exercises:
Modify your sine function based on a Taylor series to output a table. The first column of the table should be angle values that go from -90 degrees to +90 degrees in increments of 10 degrees. The second column should be the correct value for the sine function (you may use the SIN() fortran function for that column. The third through seventh columns should be what your Taylor series computes for 1, 2, 3, 4 and 5 terms, respectively. Each column should have a label at the top. The number of digits printed should be appropriate to effectively communicate the accuracy of the Taylor series approximations and the decimal points, if present, should line up in each column.
In other words, make the table one of professional quality, as if your job depended on it.
After your program runs properly, run it by typing
a.out > output.txt
This will "redirect" the output of the program to be put in the file "output.txt" instead of being printed to the screen. Print out the file and submit it with your homework.
Collaborative Exercises:
- Assume that you entered the value -0.00123456789 and assigned it to the real variable X and then subsequently printed it useing How would the output appear for each of the following FORMAT statements
Code: Select all
PRINT 13, X
Code: Select all
13 FORMAT(F12.3)
Code: Select all
13 FORMAT(F10.3)
Code: Select all
13 FORMAT(F14.5)
Code: Select all
13 FORMAT(F7.2)
Code: Select all
13 FORMAT('X=',F12.3)
Code: Select all
13 FORMAT(E12.3)
Code: Select all
13 FORMAT(D12.3)
Code: Select all
13 FORMAT(D6.3)
Code: Select all
13 FORMAT('X=',F12.3)
Code: Select all
13 FORMAT('X=',/,F12.3)
Code: Select all
13 FORMAT('X=',/.T10,F12.3)
- Write a computer program that computes the area of a triangle. The user should input the (x,y) values of the three points. A good program would check that the user entered three different points, but you do not have to check that. The program should ouput
- The (x,y) values entered with three decimals after the decimal point for each value. Each (x,y) pair should be on a new line.
- The area with one decimal after the decimal point.
- The area in exponential notation.
Modify your sine function based on a Taylor series to output a table. The first column of the table should be angle values that go from -90 degrees to +90 degrees in increments of 10 degrees. The second column should be the correct value for the sine function (you may use the SIN() fortran function for that column. The third through seventh columns should be what your Taylor series computes for 1, 2, 3, 4 and 5 terms, respectively. Each column should have a label at the top. The number of digits printed should be appropriate to effectively communicate the accuracy of the Taylor series approximations and the decimal points, if present, should line up in each column.
In other words, make the table one of professional quality, as if your job depended on it.
After your program runs properly, run it by typing
a.out > output.txt
This will "redirect" the output of the program to be put in the file "output.txt" instead of being printed to the screen. Print out the file and submit it with your homework.