Toon posts:

Een komma tonen in cobol 85

Pagina: 1
Acties:

Verwijderd

Topicstarter
Hallo iedereen!,

Ik heb binnen een kleine 2 weken examen van Cobol85, ik zit bijna aan het eind van mijn te leren leerstof, echter 1 ding vind ik er niet in terug:

Ik kom via accept en compute statements tot een komma getal, bijvoorbeeld 55.25.
Echter wanneer ik dan dit bevel geef ( staat bijna helemaal onderaan)

display student(s)' ' totaalp ' ' buis

geeft hij mij 5525 (dus je moet maar raden het punt moet?)


alvast bedankt,

Groetjes jeroen

**ps: hieronder vindt je het programma:**

identification division.
program-id. extra.
data division.
working-storage section.
01 invoer.
02 student pic a(10) value "niets" occurs 10.

01 punt.
02 vaknr pic 999 value 1 occurs 10.
02 punten pic 999v99 value 0 occurs 10.
02 gem pic 999v99 value 0 occurs 10.
77 buis pic 999 value 0.
77 s pic 999 value 1.
77 v pic 999 value 1.
77 p pic 999 value 1.
77 g pic 999 value 1.
77 vakteller pic 999 value 0.
77 totaalp pic 999v99 value 0.
procedure division.

hoofd.
perform alles until student(s) = spaces
stop run.


alles.

display 'geef naam in '
accept student(s) no beep

if student(s) = spaces
stop run

else compute s = s + 1


perform 10 times

display ' geef punten vak ' vakteller ' in '
accept punten(p) no beep

if punten(p) < 10 compute buis = buis + 1
end-if


compute vakteller = vakteller + 1
compute p = p + 1


end-perform
end-if


move 1 to p

perform vakteller times
compute totaalp = totaalp + punten(p)
compute p = p + 1
end-perform


move 1 to s

display 'student totaal aantal buizen'
display '------------------------------------------'


display student(s)' ' totaalp ' ' buis
move 0 to buis
move 0 to vakteller
move 1 to p

move 0 to totaalp.

Verwijderd

COBOL:
1
2
3
4
5
6
7
77 totaalp pic 999v99 value 0.
77 display-totaalp pic ----.--.

...

move totaalp to display-totaalp
display student(s)' ' display-totaalp ' ' buis

enz.

Het is zo'n 20 jaar geleden dat ik in Cobol heb gewerkt, dus alles onder voorbehoud ;)

  • Boss
  • Registratie: September 1999
  • Laatst online: 19:07

Boss

+1 Overgewaardeerd

COBOL! Dat daar nog examen in wordt gedaan! Heb ooit nog een spoedcursus COBOL gehad toen ik een v/d 'millennium studenten' werd. Uiteindelijk nooit ene regel hoeven schrijven, gelukkig. Hele vage taal.

Heb wel verhalen gehoord dat het nog gebruikt wordt, maar eigenlijk nooit praktijk voorbeelden gezien!

The process of preparing programs for a digital computer is especially attractive, not only because it can be economically and scientifically rewarding, but also because it is an aesthetic experience much like composing poetry or music.


  • yrew
  • Registratie: Augustus 2001
  • Laatst online: 20:24
Banken draaien er nog op (volgens mij zelfs de goldkeeper van de marine)....verder sluit ik me aan bij de tweede post aan. De eerste taal die ik leerde...geweldig. En je volledige tentamen uitschrijven op tentamen-papier...en dan erachter komen dat je nog een stuk of tien variabelen moet declareren omdat die er in je psd's niet helemaal voren kwamen.....heerlijk priegelen.

edit:

2. A decimal point in a numeric field does two things: it places an actual decimal point into the file, and determines the location of the decimal for calculations. The following field is six bytes wide and has a "real decimal" in the file:

05 AMOUNT PIC 999.99.

If you view a record containing the value 123.45 in this field, you will see "123.45"

3. A "V" in the PIC clause specifies the location of an implied decimal. This is discussed later, in the section on numeric fields. The following field is five bytes wide and has an "implied decimal" at the location of the V:

05 AMOUNT PIC 999V99.

If you view a record containing the value 123.45 in this field, you will see "12345" .

dit heb ik van http://www.discinterchange.com/reading_COBOL_layouts_.html

[ Voor 58% gewijzigd door yrew op 04-01-2005 14:16 ]

Groetjes


Verwijderd

Dit maakt dus een "echte" floating point variabele aan, terwijl:
05 AMOUNT PIC 999V99.
een packed decimal variable aanmaakt, hetgeen dus iets anders is. Ik weet niet of dat in dit geval uitmaakt, maar ik meen me te herinneren dat het nogal eens moeilijk te vinden bugs wilde opleveren als je die op een verkeerde manier door elkaar gebruikt (nogmaals, het is lang geleden).

Verwijderd

Topicstarter
Verwijderd schreef op dinsdag 04 januari 2005 @ 11:49:
COBOL:
1
2
3
4
5
6
7
77 totaalp pic 999v99 value 0.
77 display-totaalp pic ----.--.

...

move totaalp to display-totaalp
display student(s)' ' display-totaalp ' ' buis

enz.

Het is zo'n 20 jaar geleden dat ik in Cobol heb gewerkt, dus alles onder voorbehoud ;)
haha zo zou het inderdaad gaan ja:-) wel een vrij omslachtige manier. soms erger ik mij zoooooooo hard aan cobol :(

Verwijderd

Topicstarter
yrew schreef op dinsdag 04 januari 2005 @ 14:08:
Banken draaien er nog op (volgens mij zelfs de goldkeeper van de marine)....verder sluit ik me aan bij de tweede post aan. De eerste taal die ik leerde...geweldig. En je volledige tentamen uitschrijven op tentamen-papier...en dan erachter komen dat je nog een stuk of tien variabelen moet declareren omdat die er in je psd's niet helemaal voren kwamen.....heerlijk priegelen.

edit:

2. A decimal point in a numeric field does two things: it places an actual decimal point into the file, and determines the location of the decimal for calculations. The following field is six bytes wide and has a "real decimal" in the file:

05 AMOUNT PIC 999.99.

If you view a record containing the value 123.45 in this field, you will see "123.45"

3. A "V" in the PIC clause specifies the location of an implied decimal. This is discussed later, in the section on numeric fields. The following field is five bytes wide and has an "implied decimal" at the location of the V:

05 AMOUNT PIC 999V99.

If you view a record containing the value 123.45 in this field, you will see "12345" .

dit heb ik van http://www.discinterchange.com/reading_COBOL_layouts_.html
dus als ik je goed versta moet er in de plaats van die 999v99, 999.99?

ga ik dadelijk eens proberen;)

bedankt voor de tip :)
Pagina: 1