resist.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!

 

PROGRAM sumresist !program starts
REAL :: R1, R2, R3 ! the first set of values
REAL :: IR1, IR2, IR3 ! the calculated set of values 
REAL :: SumI, ISumI ! also the calculated set of values
!I in SumI and ISumI means Inverted

WRITE ( UNIT = *, FMT = * ) "Welcome to my resistance calculation program" ! Input value block
WRITE ( UNIT = *, FMT = * ) "The diagram that is shown below will give you an idea of what to expect"
WRITE ( UNIT = *, FMT = * )
WRITE ( UNIT = *, FMT = * ) " R1 "
WRITE ( UNIT = *, FMT = * ) " -------XXXX------- "
WRITE ( UNIT = *, FMT = * ) " | R2 | "
WRITE ( UNIT = *, FMT = * ) "->--|------XXXX------|-->-" !Graphics for easy reference
WRITE ( UNIT = *, FMT = * ) " | R3 | "
WRITE ( UNIT = *, FMT = * ) " -------XXXX------- "
WRITE ( UNIT = *, FMT = * ) "WARNING : Inputing the value of zero will cause the program to crash"
WRITE ( UNIT = *, FMT = * ) !visual aid for easy viewing
WRITE ( UNIT = *, FMT = * ) "Please enter the value for R1" !user inputs value as according to diagram
WRITE ( UNIT = *, FMT = * ) !visual aid for easy viewing
READ ( UNIT = *, FMT = * ) R1
WRITE ( UNIT = *, FMT = * ) !visual aid for easy viewing
WRITE ( UNIT = *, FMT = * ) "Please enter the value for R2" !user inputs value as according to diagram
WRITE ( UNIT = *, FMT = * ) !visual aid for easy viewing
READ ( UNIT = *, FMT = * ) R2
WRITE ( UNIT = *, FMT = * ) !visual aid for easy viewing
WRITE ( UNIT = *, FMT = * ) "Please enter the value for R3" !user inputs value as according to diagram
WRITE ( UNIT = *, FMT = * ) !visual aid for easy viewing
READ ( UNIT = *, FMT = * ) R3

IF (R1 == 0.0) THEN !error block
WRITE ( UNIT = *, FMT = * ) !to prevent user from inputing invalid value
WRITE ( UNIT = *, FMT = * ) "Sorry, there is no value"
WRITE ( UNIT = *, FMT = * ) "The program will now crash!!"
WRITE ( UNIT = *, FMT = * )
WRITE ( UNIT = *, FMT = * ) "I have WARNED you before.....HAHAHAHAHA"
WRITE ( UNIT = *, FMT = * )
ELSE
ENDIF

IF (R2 == 0.0) THEN !error block
WRITE ( UNIT = *, FMT = * ) !to prevent user from inputing invalid value
WRITE ( UNIT = *, FMT = * ) "Sorry, there is no value"
WRITE ( UNIT = *, FMT = * ) "The program will now crash!!"
WRITE ( UNIT = *, FMT = * )
WRITE ( UNIT = *, FMT = * ) "I have WARNED you before.....HAHAHAHAHA"
WRITE ( UNIT = *, FMT = * )
ELSE
ENDIF

IF (R3 == 0.0) THEN !error block
WRITE ( UNIT = *, FMT = * ) !to prevent user from inputing invalid value
WRITE ( UNIT = *, FMT = * ) "Sorry, there is no value"
WRITE ( UNIT = *, FMT = * ) "The program will now crash!!"
WRITE ( UNIT = *, FMT = * )
WRITE ( UNIT = *, FMT = * ) "I have WARNED you before"
WRITE ( UNIT = *, FMT = * )
ELSE
ENDIF

IF ( R1*R2*R3>0.0) THEN !revelent block:to prevent system from crashing 
IR1 = ABS ( 1 / R1 ) !calculation block
IR2 = ABS ( 1 / R2 )
IR3 = ABS ( 1 / R3 )
SumI = IR1 + IR2 + IR3
ISumI = 1 / SumI
WRITE ( UNIT = *, FMT = * ) ! Final answer printout block
WRITE ( UNIT = *, FMT = * ) 
WRITE ( UNIT = *, FMT = * ) "The equation is"
WRITE ( UNIT = *, FMT = * ) " 1/Rs = 1/", R1, "+ 1/", R2, "+ 1/",R3
WRITE ( UNIT = *, FMT = * ) "The answer for 1/Rs =", SumI, "ohm" !prints out answer for SumI
WRITE ( UNIT = *, FMT = * ) " "
WRITE ( UNIT = *, FMT = * ) "The final answer is", ISumI, "ohm" !prints out the final answer
WRITE ( UNIT = *, FMT = * )
WRITE ( UNIT = *, FMT = * ) "Have a nice day" !goodbye message
WRITE ( UNIT = *, FMT = * ) "Good day"
WRITE ( UNIT = *, FMT = * )
WRITE ( UNIT = *, FMT = * )
ENDIF 


END PROGRAM sumresist !program end