Code:
PROGRAM sim
! This code is used to solve two simultaneous
! equations in two variables with real coefficients:
!
! DATE: DEVELOPER: CHANGES:
! ------ ----------- ----------
! 12/28/13 Faiz Lo Original Code
!
IMPLICIT NONE
! Dictionary Data: Declare variables
REAL :: x, y, a1, b1, a2, b2, c1, c2
CHARACTER :: Ans
! Salut message
WRITE (*,*) '**************************************'
WRITE (*,*) '* *'
WRITE (*,*) '* This code is used to solve two *'
WRITE (*,*) '* simultaneous equations in two *'
WRITE (*,*) '* variables of the form *'
WRITE (*,*) '* a1*x + b1*y = c1, *'
WRITE (*,*) '* a2*x + b2*y = c2. *'
WRITE (*,*) '* *'
WRITE (*,*) '**************************************'
! Ask the user for inputs
100 WRITE (*,*) ''
WRITE (*,*) ' Please enter a1:'
READ (*,*) a1
WRITE (*,*) ''
WRITE (*,*) ' Please enter b1:'
READ (*,*) b1
WRITE (*,*) ''
WRITE (*,*) ' Please enter c1:'
READ (*,*) c1
WRITE (*,*) ''
WRITE (*,*) ' Please enter a2:'
READ (*,*) a2
WRITE (*,*) ''
WRITE (*,*) ' Please enter b2:'
READ (*,*) b2
WRITE (*,*) ''
WRITE (*,*) ' Please enter c2:'
READ (*,*) c2
WRITE (*,*) ''
! calculations
x = ( (b2*c1) - (b1*c2) ) / ( a1*b2 - a2*b1 )
y = ( (a2*c1) - (a1*c2) ) / ( a2*b1 - a1*b2 )
! Write the answers
WRITE (*,*) ' The value of "x" is:', x
WRITE (*,*) ' The value of "y" is:', y
WRITE (*,*) ''
! Do you want to try again?
WRITE (*,*) ' Do you want to solve another pair '
101 WRITE (*,*) ' Please answer yes or no'
READ (*,*) Ans
IF (Ans == "yes") THEN
GOTO 100
ELSEIF (Ans == "no") THEN
WRITE (*,*) ' Good Bye!'
ELSE
GOTO 101
ENDIF
STOP
END PROGRAM sim