dmv.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 menuof_dmv !dmv=density, mass, volume
IMPLICIT NONE

INTEGER :: n


!This a numeric help menu
1 PRINT*, " *********Welcome to ADCY dmv Calculator*********"
PRINT*, " (1)Calculate density by inputing mass and volume" 
PRINT*, " (2)Calculate mass by inputing density and volume"
PRINT*, " (3)Calculate volume by inputing mass and density"
PRINT*, " (4)Readme"
PRINT*, " (5)Quit"
PRINT*, " ************************************************"
PRINT*
READ*, n

IF (n==1) THEN 
CALL density1
GOTO 1
ELSE IF (n==2) THEN
CALL mass1
GOTO 1
ELSE IF (n==3) THEN 
CALL volume1
GOTO 1
ELSE IF (n==4) THEN
CALL help
GOTO 1
ELSE IF (n==5) THEN
GOTO 2
ELSE 
PRINT*, "Invalid selection of menu option. Try again."
GOTO 1
END IF
2 PRINT*
PRINT*, "Thank you for ADCY dmv Calculator"
PRINT*, "Have a nice day. :)"

END PROGRAM menuof_dmv
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SUBROUTINE density1
IMPLICIT NONE

REAL :: density, mass, volume

PRINT*, "Calculate density by inputing mass and volume"
3 PRINT*, "Please enter the value of mass (in kg) and volume (in meter cube)"
PRINT*, "Mass?"
READ*, mass
PRINT*, "Volume?"
READ*, volume

IF ((mass<0) .or. (volume<0)) THEN
PRINT*, "That value of mass or volume is invalid."
PRINT*, "Mass and volume must be of positive value."
PRINT*, "Please try again."
GOTO 3
ELSE
END IF

density=mass/volume
PRINT*, "The calculated density for give mass and volume is:"
PRINT*, density, "kg/m cube"
PRINT*

RETURN
END SUBROUTINE density1
!----------------------------------------------------------------------------------------------
SUBROUTINE mass1
IMPLICIT NONE

REAL :: density, mass, volume

PRINT*, "Calculate mass by inputing density and volume"
4 PRINT*, "Please enter the value of density (in kg/meter cube) and volume (in meter cube)"
PRINT*, "Density?"
READ*, density
PRINT*, "Volume?"
READ*, volume

IF ((density<0) .or. (volume<0)) THEN
PRINT*, "That value of density or volume is invalid."
PRINT*, "Density and volume must be of positive value."
PRINT*, "Please try again."
GOTO 4
ELSE
END IF

mass=density*volume
PRINT*, "The calculated density for give mass and volume is:"
PRINT*, mass, "kg"
PRINT*

RETURN
END SUBROUTINE mass1
!----------------------------------------------------------------------------------------------
SUBROUTINE volume1
IMPLICIT NONE

REAL :: density, mass, volume

PRINT*, "Calculate volume by inputing mass and density"
5 PRINT*, "Please enter the value of density (in kg/meter cube) and mass (in kg)"
PRINT*, "Density?"
READ*, density
PRINT*, "Mass?"
READ*, mass

IF ((density<0) .or. (mass<0)) THEN
PRINT*, "That value of density or mass is invalid."
PRINT*, "Density and mass must be of positive value."
PRINT*, "Please try again."
GOTO 5
ELSE
END IF

volume=mass/density
PRINT*, "The calculated density for give mass and density is:"
PRINT*, volume, "meter cube"
PRINT*

RETURN
END SUBROUTINE volume1
!----------------------------------------------------------------------------------------------
SUBROUTINE help

PRINT*, "This is a program to calculate the density, mass or volume IF given the other"
PRINT*, "two variables. It is done according to the formula:"
PRINT*, " density=mass/volume"
PRINT*, "To get the answers for mass or volume, the equation is appropriately modified. For&
& units compatibility, input only values using SI units."
PRINT*
RETURN
END SUBROUTINE help