| Author |
Message |
bigman9
|
Posted: Thu Jan 20, 2011 8:32 pm Post subject: RE:Help. Exiting program? |
|
|
| my bad, i fixed it with some thens. But it doesnt work. the 0 does notta |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
ProgrammingFun

|
Posted: Thu Jan 20, 2011 8:33 pm Post subject: RE:Help. Exiting program? |
|
|
| can you post the code? |
|
|
|
|
 |
bigman9
|
Posted: Thu Jan 20, 2011 8:34 pm Post subject: RE:Help. Exiting program? |
|
|
yeah. okay but heres the thing. i want it to be so that the second input must be 0 for the program to exit
var pick : real := 0
var number : real
var chars : array char of boolean
put "Please enter the number that you wish to expariment with (0 is to exit)"
get pick
loop
if pick = 0 then
put "Select your choice of calculation:"
put "1) Square of the number"
put "2) Square root of the number"
put "3) Reciprocal of the number"
put "4) Cube of the number"
put "5) Cube root of the number"
put "0) Exit program"
get number
end if
if pick = 0 then
number := 0
end if
if number = 1 then
put pick * pick
end if
if number = 2 then
put sqrt (pick)
end if
if number = 3 then
put pick / (pick * pick)
end if
if number = 4 then
put pick * pick * pick
end if
if number = 5 then
put pick ** (1 / 3)
end if
if number = 0 then
exit
end if
end loop |
|
|
|
|
 |
bigman9
|
Posted: Thu Jan 20, 2011 8:36 pm Post subject: RE:Help. Exiting program? |
|
|
| could my variable declarations be wrong? |
|
|
|
|
 |
ProgrammingFun

|
Posted: Thu Jan 20, 2011 8:48 pm Post subject: RE:Help. Exiting program? |
|
|
| Turing: |
if pick = 0 then /*<----- this is supposed to be "not equals to"*/
put "Select your choice of calculation:"
put "1) Square of the number"
put "2) Square root of the number"
put "3) Reciprocal of the number"
put "4) Cube of the number"
put "5) Cube root of the number"
put "0) Exit program"
get number
end if
|
|
|
|
|
|
 |
RandomLetters
|
Posted: Thu Jan 20, 2011 8:54 pm Post subject: Re: Help. Exiting program? |
|
|
if pick = 0 then
put "Select your choice of calculation:"
put "1) Square of the number"
put "2) Square root of the number"
put "3) Reciprocal of the number"
put "4) Cube of the number"
put "5) Cube root of the number"
put "0) Exit program"
get number
end if
if pick = 0 then
number := 0
end if
What is wrong here? Follow through the code and think about what it is doing. |
|
|
|
|
 |
bigman9
|
Posted: Thu Jan 20, 2011 8:55 pm Post subject: RE:Help. Exiting program? |
|
|
it doesnt work....
i have this code now. the thiing is is that when i put if keys ('O')<---(thats a oh) it works. But it wont wont work if theres a ZERO there |
|
|
|
|
 |
bigman9
|
Posted: Thu Jan 20, 2011 8:56 pm Post subject: RE:Help. Exiting program? |
|
|
var pick: real:=0
var number: real
var keys : array char of boolean
put "Please enter the number that you wish to expariment with"
get pick
loop
Input.KeyDown (keys)
put "Select your choice of calculation:"
put "1) Square of the number"
put "2) Square root of the number"
put "3) Reciprocal of the number"
put "4) Cube of the number"
put "5) Cube root of the number"
put "0) Exit program"
get number
if number = 1 then
put pick*pick
end if
if number = 2 then
put sqrt(pick)
end if
if number = 3 then
put pick/(pick*pick)
end if
if number = 4 then
put pick*pick*pick
end if
if number = 5 then
put pick**(1/3)
end if
if keys ('O') then
exit
end if
end loop |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
ProgrammingFun

|
Posted: Thu Jan 20, 2011 8:58 pm Post subject: RE:Help. Exiting program? |
|
|
You still don't understand...
Why don't you try what I indicated in the last comment? Or maybe what RandomLetters suggested. (They are both the same thing) |
|
|
|
|
 |
RandomLetters
|
Posted: Thu Jan 20, 2011 9:01 pm Post subject: Re: Help. Exiting program? |
|
|
Quote: if keys ('O') then
exit
end if
end loop
You're making things more complicated then they need to be.
If what you used for the other options worked, why not keep using the same thing? |
|
|
|
|
 |
bigman9
|
Posted: Thu Jan 20, 2011 9:02 pm Post subject: RE:Help. Exiting program? |
|
|
| i am doing an assignment. so the 0 has to be the second input |
|
|
|
|
 |
bigman9
|
Posted: Thu Jan 20, 2011 9:10 pm Post subject: RE:Help. Exiting program? |
|
|
this is so frusterating! |
|
|
|
|
 |
bigman9
|
Posted: Thu Jan 20, 2011 9:10 pm Post subject: RE:Help. Exiting program? |
|
|
| if someone can post the who correct program il give them all my bits |
|
|
|
|
 |
Tony

|
Posted: Thu Jan 20, 2011 9:24 pm Post subject: Re: RE:Help. Exiting program? |
|
|
bigman9 @ Thu Jan 20, 2011 9:10 pm wrote: if someone can post the who correct program il give them all my bits
That is not what we do, and it would defeat the point of the assignment, don't you think? |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
 |
bigman9
|
Posted: Thu Jan 20, 2011 9:27 pm Post subject: RE:Help. Exiting program? |
|
|
| ive donew the whole thing!!!! i just dont know how to exit it!!!!!!!!!!!!!!!!!!!!! |
|
|
|
|
 |
|