ICS 101 - Computer programming
Lab # 13
Read from File
Write to File
Write a program that reads unknown number of integers from a file INPUT.DAT and writes the positive integers into a file POSITIVE.DAT and the negative integers into a file NEGATIVE.DAT. Assume that each line of the file INPUT.DAT contains one value.
1. Create New Project workspace (e.g. LAB13)
2. Add data file with a name (e.g. INPUT.DAT) in the project workspace
3. In the active window, type in the following input
4. Add FORTRAN file with a name (e.g. P1.FOR) in the same project workspace
5. In the active window, type in the following program starting after the green line.
Following is the output of the program
6. After the program is executed, it will create the following two output files:
Write a program that reads unknown number of positive integers from a file INPUT.DAT and writes the odd integers into a file ODD.DAT and the even integers into a file EVEN.DAT. Assume that each line of the file INPUT.DAT contains one value.
Each line of a file INPUT.DAT contains the ID number of a student and his three quiz grades (Real numbers). The number of data lines in the file is not known. Write a program which will read the data from the file and write in another file OUTPUT.DAT each student ID and his average in the three quizzes. The program should then write in the OUTPUT.DAT file the overall average.
Write a program that reads unknown real numbers from a file and writes in another file OUTPUT.DAT the average and the percentage of values above the average. Do not use an array. Assume that each line of the file contains one value.
HINT: Use the REWIND statement.