2unknown.f90

I suggest you either typed  this as it appears into the compiler, or as an easier way, just copy and paste it!

Note: I do not claim the program will 100% work, but I give it my best. If it doesn't, try tweaking it yourself, or email me about it, and I'll modify and post the improved version later. Good luck!

 

! Dated 13/06/2000

! ***WARNING : THIS IS AN IMPROVED VERSION!!!***


PROGRAM twounknown !program starts
REAL :: a, b, c, d, e, f !variable list
DOUBLE PRECISION :: X, Y !double precision is used to maximise the decimal points area

WRITE ( UNIT = *, FMT = * ) "Welcome the the program that helps you solve two simultaneous equations..." ! data input block
WRITE ( UNIT = *, FMT = * ) "Read on to know how" !introduction page to tell user what to do
WRITE ( UNIT = *, FMT = * )
WRITE ( UNIT = *, FMT = * ) "Below is a sample of equation with all the variables (the value of which will"
WRITE ( UNIT = *, FMT = * ) "be keyed in by you) and two unknowns, x and y" !further introduction
WRITE ( UNIT = *, FMT = * )
WRITE ( UNIT = *, FMT = * ) " ax + by = c -----(1)" !visual representation of equation used
WRITE ( UNIT = *, FMT = * ) " dx + ey = f -----(2)" !visual representation of equation used
WRITE ( UNIT = *, FMT = * )
WRITE ( UNIT = *, FMT = * ) "Please key the values for a to f in corresponding order:"
READ*, a, b, c, d, e, f

X = (c*b*d - c*a*e - b*c*d + a*b*f) / (a*b*d - a*a*e) ! calculation block
Y = (c*d - a*f) / (b*d - a*e)

WRITE ( UNIT = *, FMT = * ) !output block
WRITE ( UNIT = *, FMT = * )
WRITE ( UNIT = *, FMT = * ) "The numbers you've just inputed will give you an equation as follows:"
WRITE ( UNIT = *, FMT = * )
WRITE ( UNIT = *, FMT = * ) a, "x + ", b, "y = ", c, " -----(1)" !verification of inputed data
WRITE ( UNIT = *, FMT = * ) d, "x + ", e, "y = ", f, " -----(2)"
WRITE ( UNIT = *, FMT = * ) 
WRITE ( UNIT = *, FMT = 10 ) "x = ", X !the output command line for X
WRITE ( UNIT = *, FMT = * ) " and"
WRITE ( UNIT = *, FMT = 10 ) "y = ", Y !the output command line for Y
WRITE ( UNIT = *, FMT = * )
WRITE ( UNIT = *, FMT = * ) "Have a nice day" !goodbye message
WRITE ( UNIT = *, FMT = * ) "Good bye"

10 FORMAT (1x, "The calculated value", 1X, A4, SP, F11.5 ) ! format line

END PROGRAM twounknown !program ends

 

BACK