sqrt2.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 sqrt2
IMPLICIT NONE
REAL :: a, b, c, d
REAL :: x1, x2
INTEGER:: ans, disc

PRINT*, "Welcome to ADCY Discriminant Calculation Program"
PRINT*
1 PRINT*, "Enter value for a"
READ*, a
PRINT*, "And for b"
READ*, b
PRINT*, "Finally... for c"
READ*, c

disc = b**2-4*a*c

IF (a==0) THEN
GOTO 5
ELSE 
END IF

SELECT CASE (disc)

CASE (:-1) 
GOTO 4
CASE (0) 
GOTO 3
CASE (1:)
GOTO 7
END SELECT 

!if disc = 0
3 x1=-b/2*a
PRINT*, "The discriminant is", disc
PRINT*, "The value you have just typed on will give you a root of ", x1
PRINT*, "It means that the quadratic equation as represented by ax**2+bx+c=0"
PRINT*, "will give a twin root; a pair of root in which the two roots"
PRINT*, "are of the same value"
PRINT*
GOTO 6

!if disc >0
7 PRINT*, "The discriminant is", disc
x1=(-b+(b**2-4*a*c)**0.5)/2*a
x2=(-b-(b**2-4*a*c)**0.5)/2*a
PRINT*, "The root of the value you have entered is", x1, "and", x2
PRINT*, "You see, this discriminant will produce two dis-similar"
PRINT*, "value of roots as according to the following formula:"
PRINT*, "(-b+-(b**2-4*a*c)**0.5)/2*a"
PRINT*
GOTO 6

!if disc < 0
4 PRINT*, "This program does not allow you to input a value that will spew out"
PRINT*, "complex numbers. The values for a, b&c that you have just inputed violates"
PRINT*, "this rule. Please enter another set of values"
PRINT*
GOTO 6

!if some idiot inputed the value of zero for a
5 PRINT*, "The value you inputed are not calculatable!"
PRINT*, "Please try another set of values, this time with a DIFFERENT value for a!"
PRINT*
GOTO 6

!confirmation block
6 PRINT*
PRINT*, "Please make your choice"
PRINT*, "(1 for yes, 2 for no)"
PRINT*, "Please do not enter any other characters"
READ*, ans
IF (ans==1) THEN
GOTO 1
ELSE IF (ans==2) THEN
GOTO 2
ELSE IF (ans/=1 .or. ans/=2) THEN
GOTO 8
ELSE
END IF

!error block
8 PRINT*, "Wrong input. Try again"
GOTO 6

!ending
2 PRINT*
PRINT*, "Thank you for calculating with ADCY Discriminant Calculation Program"
PRINT*, "Have a nice day :)"

END PROGRAM sqrt2