How can I write a quick program in fortran. I need to ask 3 questions with an option to exit after each question.
A:
Though this may be true, I was trying to refresh my memory to help my niece.
staci green
2008-11-29 14:03:30
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
2008-11-29 14:25:42
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
2008-11-29 14:33:02
I think the tutorial I linked should give you what you need.
Brabster
2008-11-29 15:01:55
+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
2008-11-29 15:23:27
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
2008-11-29 19:57:12