Computer Science Canada Dice Program + Pie Graph |
| Author: | TomYoung [ Tue Apr 05, 2011 7:14 pm ] |
| Post subject: | Dice Program + Pie Graph |
%Procudure For Dice One procedure Dice1 var f : array 1 .. 6 of nat for d : 1 .. 6 f (d) := 0 end for var rollss : int var rolling:int:=1 put "How many times are each dice rolled?" get rollss cls randomize var c : int for z:1..rollss randint (c,1,6) put "This is roll number: ",rolling put "Number Rolled: ".. if c >= 1 and c <= 6 then f(c) := f (c) + 1 rolling:=rolling+1 end if if c=4 then put "4" elsif c = 5 then put "5" elsif c = 1 then put "1" elsif c = 2 then put "2" elsif c = 3 then put "3" elsif c = 6 then put "6" end if delay (750) cls end for for d : 1 .. 6 % Print frequency of capital letters put d, " ", f(d) %%%%%%%%%%%%%%%%%%%%%%%% var a:real drawoval (250,250,100,100,7) a:= 360 * (f(d) / rollss) var aa:real aa:= a Draw.FillArc (250,250,100,100,0,aa,1) Draw.FillArc (250,250,100,100,0,a+a,1) Draw.FillArc (250,250,100,100,0,a+a+a,1) Draw.FillArc (250,250,100,100,0,a+a+a+a,1) Draw.FillArc (250,250,100,100,0,a+a+a+a+a,1) Draw.FillArc (250,250,100,100,0,a+a+a+a+a+a,1) end for end Dice1 Dice1 ____________________________________________________________________________________________________________________ All right, So I have this much, but it keeps saying the assigned value is the wrong type. Anyone can give me pointers? Thanks in advance. |
|
| Author: | goroyoshi [ Tue Apr 05, 2011 7:19 pm ] |
| Post subject: | RE:Dice Program + Pie Graph |
It has to be an integer or else you need to use floor/ceil/round and that seems to glitch on me try floor{it rounds the decimal down} (your real numbers) if not that then make those variables integers also i notice that your arcs will overlap eachother |
|
| Author: | TomYoung [ Tue Apr 05, 2011 7:36 pm ] |
| Post subject: | RE:Dice Program + Pie Graph |
Umm... Where am I suppose to use "round", am I suppose to still var a: real? |
|
| Author: | goroyoshi [ Tue Apr 05, 2011 7:48 pm ] |
| Post subject: | RE:Dice Program + Pie Graph |
round (variable) |
|
| Author: | TomYoung [ Tue Apr 05, 2011 7:51 pm ] |
| Post subject: | Re: RE:Dice Program + Pie Graph |
goroyoshi @ Tue Apr 05, 2011 7:48 pm wrote: round (variable)
Hahaha, yeah thanks. Going to figure out my pie graphing now! I just got to figure out an array. Thanks so much. Edit: If you have any suggestions for me, I would love to hear them! |
|
| Author: | goroyoshi [ Tue Apr 05, 2011 7:58 pm ] |
| Post subject: | RE:Dice Program + Pie Graph |
ok sorry was busy, so for round you need a real number, |
|
| Author: | TomYoung [ Tue Apr 05, 2011 8:21 pm ] |
| Post subject: | Re: RE:Dice Program + Pie Graph |
goroyoshi @ Tue Apr 05, 2011 7:58 pm wrote: ok sorry was busy, so for round you need a real number,
Yeah no problem. But I have encounter a NEW problem. This problem is that to fill up my pie graph, it went absolutely wrong. Any suggestions on how i can fill up my pie graph? |
|
| Author: | goroyoshi [ Tue Apr 05, 2011 8:35 pm ] |
| Post subject: | RE:Dice Program + Pie Graph |
you probably need quite a few variables for the angles |
|
| Author: | Raknarg [ Wed Apr 06, 2011 3:19 pm ] |
| Post subject: | RE:Dice Program + Pie Graph |
Note: if c=4 then put "4" elsif c = 5 then put "5" elsif c = 1 then put "1" elsif c = 2 then put "2" elsif c = 3 then put "3" elsif c = 6 then put "6" end if can all be replaced with put c Also, you can probs do that pie with one Draw.FillArc, or even better: Draw.Line if you know any trigonometry. |
|