SunQuest
           Other Programming Languages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreOther Programming Languages

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old February 14th, 2007, 10:09 AM
incognito0160 incognito0160 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2005
Location: Platteville, WI
Posts: 23 incognito0160 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 49 m 49 sec
Reputation Power: 0
First cobol program (gpa calculator)

just started Cobol this semester and need some help with my first program. When I go to run it doesn't fully run my first paragraph. It doesnt' prompt me for a response 'yes/no'

any ideas on what to do? also some help with structure and other tips would be great as it's hard to understand my teacher.

Code:
******************************************************************
      * This program determines the semester GPA and the cumlative GPA
      * of the student.  The user inputs their student number, then
      * asks for info about one course which is the course number,
      * credits, and grade.
      *                                                                *
      ******************************************************************
      *
       Environment Division.
      *
       Data Division.
      *
       Working-Storage Section.
      *
       01 WS-Student-Data.
      *
           05 WF-Student-Number        pic 9(5).
           05 WF-Course-Number         pic 9(6).
           05 WF-Credit-Hours          pic 9.
           05 WF-Grade                 pic 99.

       01 WS-Switches.
           05 WD-Response              pic x(3).
           05 WD-New-Student           pic x(3).

       01 WS-Total.
           05 WT-Student-Count         pic 9(3).
           05 WT-Cumlative             pic 99v999.
           05 WT-Credits               pic 99.
           05 WT-Total-Grade           pic 99.
           05 WT-All-Students-GPA      pic 99v999.
           05 WT-All-Students-Credits  pic 999.
      *
       Procedure Division.
      *
       000-Main-Rtn.
      *
           Perform 100-Init-Rtn Thru 100-Init-Rtn-Exit
               Until WD-Response = 'no'
           Perform 200-Process-Rtn Thru 200-Process-Rtn-Exit
               Until WD-Response = 'no'
           Perform 300-Display-Rtn Thru 300-Display-Rtn-Exit
           Display 'END OF SESSION'.
      *
       100-Init-Rtn.
      *
           Display 'Please enter your student number & press enter key'
           Accept WF-Student-Number
           Display 'Please enter the course number & press enter key'
           Accept WF-Course-Number
           Display 'Please enter the number of credits & press enter'
           Accept WF-Credit-Hours
           Display 'Please enter your grade & press enter key'
           Accept WF-Grade.
           If WF-Grade = 'A'
               Add 4 to WF-Grade
           If WF-Grade = 'B'
               Add 3 to WF-Grade
           If WF-Grade = 'C'
               Add 2 to WF-Grade
           If WF-Grade = 'D'
               Add 1 to WF-Grade
           If WF-Grade = 'F'
               Add 0 to WF-Grade
           Add WF-Credit-Hours to WT-Credits
           Add WF-Grade to WT-Total-Grade
           Display 'Do you have another class to enter yes/no?'
           Accept WD-Response
           if WD-Response = 'no'
               Display WF-Student-Number
           Divide WT-Total-Grade by WT-Credits giving WT-Cumlative
               Display WT-Cumlative
           Add WT-Cumlative to WT-All-Students-GPA
           Add WT-Credits to WT-All-Students-Credits.

      *
       100-Init-Rtn-Exit. Exit.
      *
       200-Process-Rtn.
      *
           Initialize WD-Response
           Initialize WD-New-Student
           Display 'Is there another students GPA you wish to
      -'enter yes/no'.
           if WD-New-Student = 'yes'
               add 1 to WT-Student-Count
           Accept WD-New-Student
           Display 'Please enter your student number & press enter key'
           Accept WF-Student-Number
           Display 'Please enter the course number & press enter key'
           Accept WF-Course-Number
           Display 'Please enter the number of credits & press enter'
           Accept WF-Credit-Hours
           Display 'Please enter your grade & press enter key'
           Accept WF-Grade.
           Display 'Do you have another class to enter yes/no'
           Accept WD-Response.
           if WD-Response = 'no'
               Display WF-Student-Number
               Divide WT-Total-Grade by WT-Credits giving WT-Total-Grade
               WT-Credits
               Display WT-Cumlative
           Add WT-Cumlative to WT-All-Students-GPA
           Add WT-Credits to WT-All-Students-Credits.

       200-Process-Rtn-Exit.  Exit.
      *
       300-Display-Rtn.
      *
           Divide WT-All-Students-GPA into WT-All-Students-Credits
           Display WT-All-Students-Credits.
      *
       300-Display-Rtn-Exit.  Exit.

Reply With Quote
  #2  
Old February 15th, 2007, 12:09 AM
Purple Avenger Purple Avenger is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2006
Posts: 271 Purple Avenger User rank is Sergeant (500 - 2000 Reputation Level)Purple Avenger User rank is Sergeant (500 - 2000 Reputation Level)Purple Avenger User rank is Sergeant (500 - 2000 Reputation Level)Purple Avenger User rank is Sergeant (500 - 2000 Reputation Level)Purple Avenger User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 1 h 51 m 31 sec
Reputation Power: 9
My old 87' vintage Microfocus compiler wouldn't compile it. It threw three syntax errors. Two missing periods and an undeclared function name.

Are you sure its even compiling?

Reply With Quote
  #3  
Old February 16th, 2007, 01:02 AM
Schol-R-LEA's Avatar
Schol-R-LEA Schol-R-LEA is offline
Commie Mutant Traitor
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jun 2004
Location: The People's Republic of Berkeley
Posts: 1,082 Schol-R-LEA User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Schol-R-LEA User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Schol-R-LEA User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Schol-R-LEA User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Schol-R-LEA User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Schol-R-LEA User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Schol-R-LEA User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Schol-R-LEA User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Schol-R-LEA User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Schol-R-LEA User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Schol-R-LEA User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 10 h 21 m 50 sec
Reputation Power: 446
Now, I only have a passing familiarity with COBOL, but if I recall correctly,
Code:
05 WF-Grade                 pic 99.

declares WF-Grade as a 2-digit decimal value, right? Whereas in Init-Rtn, you use it first as a character value, then as a decimal:
Code:
           Display 'Please enter your grade & press enter key'
           Accept WF-Grade.
           If WF-Grade = 'A'
               Add 4 to WF-Grade
           If WF-Grade = 'B'
               Add 3 to WF-Grade
           If WF-Grade = 'C'
               Add 2 to WF-Grade
           If WF-Grade = 'D'
               Add 1 to WF-Grade
           If WF-Grade = 'F'
               Add 0 to WF-Grade

Furthermore, there's no short-circuiting of the tests; even once you have the numeric value of WF-Grade assigned, you are still comparing it (up to four times) with a character value.

I suspect what you meant to do is have another variable, say,
Code:
05 WF-Letter-Grade                 pic X.

in which to hold the letter grade. For the other part, once you fix the variables it shouldn't make a difference for the program flow, but it may slow things down a bit; I think you'd be better off replacing the IF statements with a SEARCH on a table with the pairs of letter grades and grade values (don't recall how you do that offhand, or even if I have the keyword right). Otherwise, you'll need to use nested IF/ELSE/END-IFs to avoid repeatedly testing the value unnecessarily.

It sounds like whatever compiler you're using is very lax on syntax checking...
__________________
Rev First Speaker Schol-R-LEA;2 JAM LCF ELF KoR KCO BiWM TGIF
#define KINSEY (rand() % 7) λ Scheme is the Red Pill
Scheme in ShortUnderstanding the C/C++ Preprocessor
Taming PythonA Highly Opinionated Review of Programming Languages for the Novice, v1.1

FOR SALE: One ShapeSystem 2300 CMD, extensively modified for human use. Includes s/w for anthro, transgender, sex-appeal enhance, & Gillian Anderson and Jason D. Poit clone forms. Some wear. $4500 obo. tverres@et.ins.gov

Last edited by Schol-R-LEA : February 16th, 2007 at 01:11 AM.

Reply With Quote
  #4  
Old February 16th, 2007, 07:17 AM
incognito0160 incognito0160 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2005
Location: Platteville, WI
Posts: 23 incognito0160 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 49 m 49 sec
Reputation Power: 0
Sweet, thanks for the help. You're right about inputting a number compared to a letter. Totally missed that.

As for a compiler, on this first program he made us use PersonalCobol. The next one we are using something else, not sure of the name.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreOther Programming Languages > First cobol program (gpa calculator)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway