Posted: 6/21/2009 7:58:33 AM EDT
|
I'm not a programmer, this pretty much my first attempt at this sort of thing...
I'm having an issue with this little piece of code...I'm getting a "Will not execute" error for the line after this bit, so this obviously is an endless loop... I can't really find any good examples of SELECT CASE constructs...I know that is where the issue is... Any ideas on how to fix it? |
|
I'm not a Fortran programmer (thank the gods) but I do wonder what (and where) is the exit condition from the DO loop? In addition the strings used for the perimeter and area answers are the same and it appears that you are making the perimeter calculation for the area case and the area calculation for the perimeter case.
BTW: If you are new to programming, the languages of choice are Pascal or a modern version of BASIC. Unless you are required to use Fortran, I would switch languages. This looks very much like a homework assignment, so you may well be stuck with it. If not, Turbo Delphi (A modern Pascal Development system) is available here: http://turboexplorer.com/downloads |
|
Was it Fortran or Cobol that was used by the banks back in the day? I remember playing with Forth in junior highschool, thought it was a neat language after mastering Basic.
We had a guy come to my shop a few years ago that worked for a bank as a programmer. His language specialty fell out of fashion decades ago and the banks at some point decided that they didn't need programmers like him anymore so they got rid of him once they had a system that worked. Turned out that he got his revenge-programmers like him were able to write their own ticket pay wise 10-15 years later. |
|
Quoted:
I'm not a programmer, this pretty much my first attempt at this sort of thing... I'm having an issue with this little piece of code...I'm getting a "Will not execute" error for the line after this bit, so this obviously is an endless loop... I can't really find any good examples of SELECT CASE constructs...I know that is where the issue is... Any ideas on how to fix it? WRITE (*, '(A)', ADVANCE = "NO") "Would you like to calculate the area or the perimeter of the triangle?" READ *, Calculation 2 DO SELECT CASE (Calculation) CASE ("area", "A", "a", "Area", "AREA") P = S1+S2+S3 PRINT *, "The perimeter of the triangle with sides S1, S2, & S3 is", P, "centimeters." CASE ("perimeter", "P", "p", "Perimeter", "PERIMETER") SP = P *.5 A = SQRT(SP*(SP-S1)*(SP-S2)*(SP-S3)) PRINT *, "The perimeter of the triangle with sides S1, S2, & S3 is", A, "centimeters." CASE DEFAULT WRITE (*, '(A)', ADVANCE = "NO") "INPUT ERROR - PLEASE ENTER PERIMETER OR AREA:" READ *, Calculation GOTO 2 END SELECT END DO PRINT * Depending on the version of Fortran, you might be able to do this with DO WHILE or DO UNTIL. If it's truly ancient, though, you'd be better off with just IF/GOTO, like this: WRITE (*, '(A)', ADVANCE = "NO") "Would you like to calculate the area or the perimeter of the triangle?" 10 Retardeduser=0 READ *, Calculation SELECT CASE (Calculation) CASE ("area", "A", "a", "Area", "AREA") P = S1+S2+S3 PRINT *, "The perimeter of the triangle with sides S1, S2, & S3 is", P, "centimeters." CASE ("perimeter", "P", "p", "Perimeter", "PERIMETER") SP = P *.5 A = SQRT(SP*(SP-S1)*(SP-S2)*(SP-S3)) PRINT *, "The perimeter of the triangle with sides S1, S2, & S3 is", A, "centimeters." CASE DEFAULT WRITE (*, '(A)', ADVANCE = "NO") "INPUT ERROR - PLEASE ENTER PERIMETER OR AREA:" Retardeduser=1 END SELECT IF Retardeduser=1 GOTO 10 PRINT * |
|
Quoted:
Was it Fortran or Cobol that was used by the banks back in the day? I remember playing with Forth in junior highschool, thought it was a neat language after mastering Basic. We had a guy come to my shop a few years ago that worked for a bank as a programmer. His language specialty fell out of fashion decades ago and the banks at some point decided that they didn't need programmers like him anymore so they got rid of him once they had a system that worked. Turned out that he got his revenge-programmers like him were able to write their own ticket pay wise 10-15 years later. COBOL is still used by banks/fed reserve/airlines today. It may be old and laborious but it is rock solid dependable. |
|
Quoted:
I learned how to do FORTRAN while getting an engineering degree in the early 1970s. I had to punch everything in on data cards and then run it though a card reader. I thought it was ancient history and long gone. It's around in legacy systems (there's a department at work that has to deal with probably 50%-70% legacy fortran code depending on the program) - and on college campuses, where certain professors still feel that all other languages suck .
|
|
Quoted:
I learned how to do FORTRAN while getting an engineering degree in the early 1970s. I had to punch everything in on data cards and then run it though a card reader. I thought it was ancient history and long gone. And if somebody left his card stack out some wise guy might slip a few extra cards into it that made the printer go crazy spitting out paper, or even worse. I used to double up and do my Physics Homework in Fortran. About the only other thing I can remember was one of the upper classmen had a wife that was a real knockout type out his punch cards for him. |
|
Thanks for all of the replies so far...I've just copied and pasted all of the code to make it less confusing...though for some reason the tabs I have in place disappear when I click submit.
I was using the GOTO 2 to bring it back to the beginning of the CASE statement...though the CASE statement doesn't seem to be working right...and as I mentioned before I can't really find any examples of it being used... Part of the assignment is to use the CASE construct...I know I can make it work exactly as needed with a nested IF THEN's though... I'm an in a BSME program, so it was either this or C++, both are old languages, so I chose Fortran for the hell of it... Anyhow...here is all of the mess... |
|
Quoted:
I learned how to do FORTRAN while getting an engineering degree in the early 1970s. I had to punch everything in on data cards and then run it though a card reader. I thought it was ancient history and long gone. Yeah. If you'd asked me in '70 or '71 I might have been able to actually answer it.
|
|
I miss COBOL. During the 80's I was at one bank that was using COBOL-68. They wouldn't even upgrade to 74. Hated that job. I then went somewhere else that was using RM-COBOL. Easier to use. Then on to Home Shopping Network, where the mainframers (Unisys A-19) used LINC and I was still using COBOL into the 90's.
Only used Fortran in college. |
|
I figured out how to make the statement work the way I intended...
The issue now is, it's crash proof for every input...other than a "/" as the first input... I can put in some numbers/letters/symbols...and if it doesn't jive with the calculation it just prints a error message and starts over... I input a damn / and it crashes...
|


.