Bonjour,
J'ai commencé le cobol à l'école il y a quelques jours, et hop voilà j'ai un labo à faire mais je plante et je ne comprends pas pourquoi :s
C'est une appli qui calcule le sinus d'un angle selon la loi de Mac Laurin
Bon, mon programme doit faire ceci: (mais j'ai des probs :s)
Ben voilà j'ai pas vraiment ce résultat et de plus quand je saisis un angle avec virgule et que je fais Enter, il me le réaffiche sans virgule :sDemande à la saisie d'un angle en radian
demande la saisie du rang de calcul
Calcul et affiche le resultat
Afficher une boite de dialogue: voulez vous travaillez avec le même angle?
si l'utilisateur répond Oui on redemande le rang uniquement
S'il répond Non, on affiche une autre boite de dialogue:
Voulez vous calculer le sinus d'un autre angle? Donc s'il répond oui on refait tout, sinon on quitte l'application.
Voilà le code source et merci d'avance pour l'aide:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130 IDENTIFICATION DIVISION. PROGRAM-ID. Sin-McLaurin. INSTALLATION. comment-entry. DATE-WRITTEN. 1999/XX/XX - 99:99:99. DATE-COMPILED. 1999/XX/XX - 00:00:00. ****************************************************************** ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. computer-name. OBJECT-COMPUTER. computer-name. SPECIAL-NAMES. DECIMAL-POINT is COMMA. ***************************************************************** DATA DIVISION. WORKING-STORAGE SECTION. ******************* Section de la date ************************** 01 System-Date. 03 sYear pic x(4). 03 sMonth pic x(2). 03 sDay pic x(2). ***************************************************************** 01 Angle pic S9v9(6). 01 N pic 9(2) value zero. 01 i pic 9(2) value zero. 01 ii pic 9(2) value zero. 01 Terme pic S9v9(6) value zero. 01 Sinus pic S9V9(6). 01 Flag pic 9 value zero. 78 MB-OK value 1. 78 MB-YES-NO VALUE 2. 78 MB-DEFAULT-ICON VALUE 1. 78 MB-ERROR-ICON VALUE 2. 01 UserReply pic 9. LINKAGE SECTION. * [ Data Desciption Entry ....] SCREEN SECTION. 01 HeaderScreen. 02 BLANK SCREEN BACKGROUND-COLOR 7 FOREGROUND-COLOR 0. 02 LINE 1 COL 1 VALUE "Laboratoire 3 de Belkacem et Bahizi". 02 COLUMN 68 VALUE "Le ". 02 COLUMN 71 PIC Z9 USING sDay of System-Date. 02 COLUMN 73 VALUE "/". 02 COLUMN 74 PIC Z9 USING sMonth of System-Date. 02 COLUMN 76 VALUE "/". 02 COLUMN 77 PIC 9999 USING sYear of System-Date. 02 LINE 2 COL 1 VALUE "-----------------------------------". 02 COL 68 VALUE "--------------". 02 LINE 3 COL 25 VALUE "Le sinus d'un angle - Mc Laurin". 01 AngleScreen. 02 LINE 5 COL 1 VALUE "Introduisez l'angle en Radian:". 02 LINE 5 COL 32 pic S9v9(6) USING Angle REQUIRED. 01 TermeScreen. 02 LINE 6 COL 1 VALUE "Introduisez le nombre de termes:". 02 LINE 6 COL 34 pic z9 USING N REQUIRED. 01 ResultScreen. 02 LINE 8 COL 1 VALUE 'sin('. 02 COL 5 pic 9(9) using angle. 02 COL 10 Value ')='. 02 COL 14 pic S9V9(6) using sinus. ****************************************************************** PROCEDURE DIVISION. Main Section. perform Welcome. perform Continuer with test after until UserReply = 2. perform QUIT. Welcome. ACCEPT System-Date from DATE YYYYMMDD. Display Headerscreen. Continuer. perform Demande-angle. perform Meme-Angle with test after until UserReply = 2. display MESSAGE box "Un autre angle angle?" title "Sinus Mc Laurin" type is MB-YES-NO icon is MB-default-icon giving UserReply. Demande-Angle. Display AngleScreen. ACCEPT Anglescreen. Meme-Angle. perform Demande-Terme until (N is POSITIVE) AND (N<51). perform Init-Data. perform Calcul varying i from 2 by 1 until i=N. perform Afficher-resultat. display MESSAGE box "Même angle?" title "Sinus Mc Laurin" type is MB-YES-NO icon is MB-default-icon giving UserReply. Demande-Terme. Display Termescreen. ACCEPT Termescreen. if ((terme is NEGATIVE) or (terme>50)) then display MESSAGE box "Limite du terme entre 0 et 50 inclus" title "Erreur" type is MB-OK icon is MB-ERROR-ICON. Init-Data. Move Angle to Sinus. Move Angle to Terme. Calcul. SUBTRACT 1 from i giving ii. compute terme = terme*(-angle*angle)/(2*ii)*(2*(ii)+(1)) end-compute. compute sinus=sinus+terme end-compute. Afficher-resultat. Display ResultScreen. QUIT. Exit Program. Stop Run.
Partager