1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Fortran 90

  1. Apr 6, 2012 #1
    1. The problem statement, all variables and given/known data

    REAL :: A, B, C, DISCR, X1, X2, x1i, x2i
    ! Reads the coefficients for the quadratic equation
    33 WRITE(*,*)")"Please enter a *REAL*NUMBER* coefficient ( A )."
    WRITE(*,*)"Please enter a *REAL*NUMBER* coefficient ( B )."
    WRITE(*,*)"Please enter a *REAL NUMBER* coefficient ( C )."
    WRITE(*,*)"The coefficients for A,B,C are",A,B,C

    2. Relevant equations

    This is only a little part of the whole program. My question is when I input a invalid character, like a letter or symbol, I want to tell the user that it is a error. Since A,C,B are all real variables how do I ask If I can let the user reenter a new value. Maybe an If statment? But I think you cannot compare reals and character. I am new to fortran my prof keeps failing me its my 4th time taking this course. It is very hard for me to comprehend so much details. Can someone assist me please? thank you!

    3. The attempt at a solution
  2. jcsd
  3. Apr 6, 2012 #2


    User Avatar

    Staff: Mentor

    Hi Luke1986! http://img96.imageshack.us/img96/5725/red5e5etimes5e5e45e5e25.gif [Broken]

    To validate input, you can read it as characters or a string and check that it conforms to a real before treating it as such.

    I'm sure almost any textbook would have this or something similar as an example.

    Good luck!
    Last edited by a moderator: May 5, 2017
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook