Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 what is.....
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
ecookman




PostPosted: Mon Oct 20, 2008 10:43 am   Post subject: what is.....

just wondering i am completly lost with this question i have for home work
could someone explain what i have to do NOT DO IT FOR ME

the question...

Write a program that will ask the user to
enter an integer. Your program should
check to see if the user entered a valid
integer and output an appropriate
message depending on whether the user
correctly entered an integer or not.
Hint: Review the strintok function




so just wondering what this is asking (in a dumbed down version) Mr. Green
Canada Mr. Green Razz Cool
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Mon Oct 20, 2008 11:04 am   Post subject: Re: what is.....

It's checking to make sure the user did indeed enter a number. If a letter is entered, it will say 'no, you did not enter a number', while if a number is entered, it will say 'yes, you did enter a number'.

Hints: Strintok- will check if the input can be converted to an integer.
Strint- will convert the string to an integer.

This is useful as is stops your programs from crashing due to users entering a letter when asked for an int/real.
ecookman




PostPosted: Wed Oct 22, 2008 7:51 am   Post subject: RE:what is.....

ok so somethig like this???

var num : string
var check : real
put "ello' i am a thingy.... that does something....ummmm...i think you are suposto' enter a number..."
get num
%check startment
loop
if not strrealok (num) then
put " I SAID ENTER A NUMBER"
get num
exit when strrealok (num)
end if
end loop
check := strreal (num)

put "now was entering a number so hard..????, entering the number, ",check




ANS SRRY I DON'T KNOW HOW TO MAKE THE COLORS DIFFERENT AND HAVE LIKE

Turing:
blahblah(balck and blue)
Insectoid




PostPosted: Wed Oct 22, 2008 12:21 pm   Post subject: RE:what is.....

code:

[syntax="Turing"]
%Type stuff
[/syntax]
The_Bean




PostPosted: Wed Oct 22, 2008 12:24 pm   Post subject: Re: what is.....

1) Name the topic of your post something better than "what is..."
2) If the teacher tells you to use a certain function, look it up in the help menu first and try to firgure out how to use for yourself
3) For the solution you put, if you enter an integer the first time around, you then you get stuck in a never ending loop.
4) There is alot simpler way of doing this.
5) Your suppose to use the strintok function not strrealok, even though they do a similare thing.
6) If you enter an integer right away your still being rude to the user with the last line even though they didn't do anything wrong.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: