Posted: Mon Mar 17, 2003 7:33 pm Post subject: (No subject)
k i didnt understand what the label was for. can u do it for the example i gave ????
k the below code. there is nothing wrong with. but just try it out. what i want is how can i keep the menu of operations as it is , in the sense that i want it to appear all the time but the input for calcualtion and the number should repeat and after the answer is ouputed, i want to clear the screen. such a way that the menu is as it is. i tried to put "loop" different places, didnt work. when i put cls anywhere the whole sceen excpept the input statemets remain on the sceen. that's not what i want. plz help.
var x : real
var y : real
var calc : int
var again : string (1)
var temp : real
View.Set ("graphics:450;500")
colorback (22)
cls
color (White)
put ""
put " Square Root of ----------> ", "1"
put ""
put " Absolute value ----------> ", "2"
put ""
put " Round ----------> ", "3"
put ""
put " Addition ----------> ", "4"
put ""
put " Subtraction ----------> ", "5"
put ""
put " Division ----------> ", "6"
put ""
put " Multiplication ----------> ", "7"
put ""
put " Div ----------> ", "8"
put ""
put " Mod ----------> ", "9"
put ""
put " ** ----------> ", "10"
put ""
put "--------------------------------------------------------"
loop
put "Press the number for desired calculation :"
get calc
put ""
put "Please enter a number to calculate"
get x
temp := x
put ""
if calc = 3 then
x := round (x)
put x
elsif calc = 1 then
x := sqrt (x)
put "The square root of", temp, "is",
elsif calc = 2 then
x := abs (x)
put x
elsif calc = 4 then
put "Please enter another number to calculate"
get y
x := x + y
put x
elsif calc = 5 then
put "plese enter another number"
get y
x := x - y
elsif calc = 6 then
put "plese enter another number"
get y
x := x / y
elsif calc = 7 then
put "plese enter another number"
get y
x := x * y
elsif calc = 8 then
put "plese enter another number"
get y
x := x div y
elsif calc = 9 then
put "plese enter another number"
get y
x := x mod y
elsif calc = 10 then
put "plese enter another number"
get y
x := x ** y
put "Do u want to go again (y/n)?"
getch (again)
exit when again = "y" or again = "Y"
end if
end loop
Sponsor Sponsor
Asok
Posted: Mon Mar 17, 2003 7:39 pm Post subject: (No subject)
what I would reccomend is you redraw your menu or you do a Draw.FillBox over the results beneath that line.
pheonix3000
Posted: Mon Mar 17, 2003 7:41 pm Post subject: (No subject)
how do i do that. how would i frame my commands?
Asok
Posted: Mon Mar 17, 2003 8:03 pm Post subject: (No subject)
code:
var x : real
var y : real
var calc : int
var again : string (1)
var temp : real
View.Set ("graphics:450;500")
colorback (22)
cls
color (white)
put ""
put " Square Root of ----------> ", "1"
put ""
put " Absolute value ----------> ", "2"
put ""
put " Round ----------> ", "3"
put ""
put " Addition ----------> ", "4"
put ""
put " Subtraction ----------> ", "5"
put ""
put " Division ----------> ", "6"
put ""
put " Multiplication ----------> ", "7"
put ""
put " Div ----------> ", "8"
put ""
put " Mod ----------> ", "9"
put ""
put " ** ----------> ", "10"
put ""
put "--------------------------------------------------------"
loop
locate (23,1)
put "Press the number for desired calculation :"
get calc
put ""
put "Please enter a number to calculate"
get x
temp := x
put ""
if calc = 3 then
x := round (x)
put x
elsif calc = 1 then
x := sqrt (x)
put "The square root of", temp, "is", x
elsif calc = 2 then
x := abs (x)
put x
elsif calc = 4 then
put "Please enter another number to calculate"
get y
x := x + y
put x
elsif calc = 5 then
put "plese enter another number"
get y
x := x - y
elsif calc = 6 then
put "plese enter another number"
get y
x := x / y
elsif calc = 7 then
put "plese enter another number"
get y
x := x * y
elsif calc = 8 then
put "plese enter another number"
get y
x := x div y
elsif calc = 9 then
put "plese enter another number"
get y
x := x mod y
elsif calc = 10 then
put "plese enter another number"
get y
x := x ** y
put "Do u want to go again (y/n)?"
getch (again)
exit when again = "y" or again = "Y"
end if
Draw.FillBox (0,0,400,100,22)
end loop
I decided to do it for you, notice your second half now works through locates, and the box is drawn over it at the end of the loop.
pheonix3000
Posted: Mon Mar 17, 2003 9:42 pm Post subject: (No subject)
Thanks a lot . but i do get some mistakes. like when i start with addition and with i go back to the first one, it also askes me for the second number and as a result i get 2 answers. how would i frame the "if's" if i have to say that if calc is 1 ,2 and 3 then do the first three calcualtions and the rest to ask for the second number?
Asok
Posted: Mon Mar 17, 2003 10:43 pm Post subject: (No subject)
well I can't do the whole thing for you
you should be able figure that one out on your own
pheonix3000
Posted: Thu Mar 20, 2003 10:35 pm Post subject: (No subject)
I am trying to figure out how to draw a diamond using "*" like i got how to draw a box, and a triangle. but i am getting stuck in the diamond shape.
Can u also give me some pointers on how can i make hollow patterns.like
*****
* *
* *
* *
*****
var n : int
var d : int
var count : int := 0
var size : int
put "Square : 1"
put "Triangle : 2"
put "Diamond : 3"
put "Please enter the type you want"
get n
if n = 1 then
loop
put "Please enter the size"
get size
exit when size < 21 and size > 1
end loop
loop
for i : 1 .. size
put "*" ..
end for
count := count + 1
exit when count = size
put ""
end loop
end if
if n = 2 then
loop
put "Please enter the size"
get size
exit when size < 21 and size > 1
end loop
loop
count := count + 1
for i : 1 .. count
put "*" ..
end for
exit when count = size
put ""
end loop
end if
if n = 3 then
loop
put "Please enter the size"
get size
exit when size < 21 and size > 1
end loop
for decreasing i : count .. size by 1
put " " ..
loop
count := count + 1
put "*" ..
exit when count > size
end loop
put ""
end for
end if
Tony
Posted: Thu Mar 20, 2003 10:52 pm Post subject: (No subject)
...*
..***
.*****
*******
.*****
..***
...*
see the pattern? number of spaces (. in example) decreases by 1 each line until 0 and number of * increase by 2.
when it reaches middle (number of spaces = 0) process revenses.
Posted: Thu Mar 20, 2003 10:56 pm Post subject: (No subject)
k i sort of get it. not competly though. Is this what u meant ?
if n = 3 then
loop
put "Please enter the size"
get size
exit when size < 21 and size > 1
end loop
for decreasing i : " " .. 0 by 1
put "*" ..
if i = 0 then
for i : " ".. 0 by 1
put "*" ..
exit when count > size
count := count + 1
end loop
put ""
end for
end if
Asok
Posted: Fri Mar 21, 2003 12:37 am Post subject: (No subject)
It would help if ur sample code worked, too many things wrong in it for me to attempt to decode it all. Test the code out for yourself please before you post it. Be sure to include all variable declarations to make it easier. We are trying to help you, but we need the tools to do it properly
pheonix3000
Posted: Fri Mar 21, 2003 8:46 pm Post subject: (No subject)
k here it is. The n = 3 is the diamond part. the first 2 work but not the third one.
var n : int
var d : int
var count : int := 0
var size : int
put "Square : 1"
put "Triangle : 2"
put "Diamond : 3"
put "Please enter the type you want"
get n
if n = 1 then
loop
put "Please enter the size"
get size
exit when size < 21 and size > 1
end loop
loop
for i : 1 .. size
put "*" ..
end for
count := count + 1
exit when count = size
put ""
end loop
end if
if n = 2 then
loop
put "Please enter the size"
get size
exit when size < 21 and size > 1
end loop
loop
count := count + 1
for i : 1 .. count
put "*" ..
end for
exit when count = size
put ""
end loop
end if
if n = 3 then
loop
put "Please enter the size"
get size
exit when size < 21 and size > 1
end loop
for decreasing i : 20 .. size by 1
put " " ..
loop
count := count + 1
put "*" ..
exit when count > size
end loop
put ""
end for
end if
Tony
Posted: Fri Mar 21, 2003 9:05 pm Post subject: (No subject)
wow dude, you got it all wrong... I mean look at your output, thats nowhere close!
code:
for decreasing i : size .. 0 by 1
for i2:0..i
put " "..
end for
for i3:1.. size - i * 2
put "*"..
end for
put ""
end for
that outputs your first half. now for the bottom half, you just revese it. I'd like you to figure that part out yourself.
Posted: Sat Mar 29, 2003 3:24 pm Post subject: (No subject)
wow... how do u plan on passing the gr 11 comp sci course if u cant figure anythin out on ur own? ur practically askin the mods to do every project for u... if u get any good marks u should giv tony all the credit
Tony
Posted: Sat Mar 29, 2003 3:33 pm Post subject: (No subject)
thx PrInCe_... but if I was getting marks for helping others, my compsci mark would be in 4 digits already
Posted: Sun Mar 30, 2003 9:43 am Post subject: (No subject)
PrInCe_ wrote:
wow... how do u plan on passing the gr 11 comp sci course if u cant figure anythin out on ur own? ur practically askin the mods to do every project for u... if u get any good marks u should giv tony all the credit
Some people need some time to develop their skills. I used to ask tons of questions, but now, I'm pretty much self-reliant, and basically go through the help file, and use some examples.