views:

656

answers:

5

How can I write a quick program in fortran. I need to ask 3 questions with an option to exit after each question.

+5  A: 

by reading a fortran manual? this should get you started

This tutorial looks like it should cover what you need.

Brabster
A: 

Though this may be true, I was trying to refresh my memory to help my niece.

staci green
A: 

This not a homework question, but a homework question. ??? The professor asked the students to think of a program over the holiday and they would work on them after they return. I have not have a programming class in 10yrs. So I'm a little rusty. I thought this site would help. I sorry if I disturbed anyone. My niece does not know I'm looking online, I was just suppose to look over what she has come up with.

staci green
I don't think anyone was offended. I think the answer you got was best. Just read up on a tutorial to refresh your memory. It sounds like the prof doesn't expect a fully functional program, just a good start at one.
EBGreen
I think the tutorial I linked should give you what you need.
Brabster
+4  A: 

How about something like this? (This is Fortran 90. If you use another version, please let me know.)

MODULE QuestionModule
  SUBROUTINE Ask(question, correctAnswer)
    CHARACTER(LEN=50):: question, correctAnswer, userAnswer
    CHARACTER(LEN=5):: continueQuestions
    PRINT*, question
    READ*, userAnswer
    IF (userAnswer == correctAnswer) 
    THEN
        PRINT*, "Correct"
    ELSE
        PRINT*, "Wrong"
    END IF
    PRINT*, "Would you like to continue?"
    READ*, continueQuestions
    IF (continueQuestions == "no")
        STOP
  END SUBROUTINE Ask
END MODULE QuestionModule

PROGRAM Questions
  USE QuestionModule
  CALL Ask("What is the capital of Denmark?", "Copenhagen")
  CALL Ask("What is the capital of Sweden?", "Stockholm")
  CALL Ask("Which Aztek god is often depicted as a hummingbird?", "Huitzilopochtli")
END PROGRAM Questions
Ole Lynge
A: 

Thanks a lot for your help, the tutorial did help. Also the sample program gave me something to build on. And yes it is Fortran 90.

staci green