Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

please solve this question by using a FORTRAN program thx Write a program that r

ID: 3840147 • Letter: P

Question

please solve this question by using a FORTRAN program thx Write a program that reads from the file "input.txt" and split the real numbers inside it into two parts. The part before the decimal point should be written to a file 15 called "left.txt" and the part after the decimal point should be written to a file called "right txt" as shown in the figure (this only example to help you understand the requirements. Your program should be general for any input file). left txt input.txt right .txt 12 12.34 34 956.12 956 9.09 4.00 23 -23.55 55 1234 1234.09 If there is an error in opening any of the files (input or output), your program should produce an error message indicating which file(s) cause the error. In case of any error, no need to write to output files. Note the following: The file "input.txt" contains unknown number of real numbers. Each real number in the file "input.txt" has two decimal places For negative number (e.g. -12.34), the two parts should be negative (-12 and -34). There is no need to check errors caused by the read operation. Use good programming practice but you may skip writing comments.

Explanation / Answer

program split
INTEGER :: stat,c

OPEN(1,FILE='input.txt')
OPEN(2,FILE='left.txt')
OPEN(3,FILE='right.txt')

DO WHILE(.TRUE.)
READ(1,'(1F9.2)',iostat=stat) A
IF (stat<0) EXIT
c=int(A);
WRITE (2, *) c
c=(A-c)*100.0
WRITE (3, *) c
END DO
CLOSE(1)
end program split