Author |
Message |
computerguy
|
Posted: Wed Apr 11, 2007 4:29 pm Post subject: A lot of questions... |
|
|
I have a bunch of assignments I haven't been able to completely figure out, I was wondering if some of you could give me some pointers??
First off is something called "Guess the Number Game" where the user inputs the starting number, ending number, and then enters a series of guesses until they are correct. The part I'm having the most trouble with is that the user may EXIT the program at any time.
Next is a "String Assignment" where the user must enter information such as their first and last name street address, city, province, country..ALL on one line but it outputs the information as follows
NAME
ADDRESS
CITY
PROVINCE
COUNTRY
Then comes a POSTAL CODE assignment. I had worked on this forever and had no clue, so ideas would be great. I need to write a program that will output a postal code corrects, eg: L7G 2R5... so if somebody inputs l7g2r5, it will display L7G 2R5.
I also need the program to tell the user if it is in correct, for example if a number is in the lpace of a letter.
Thanks SO much!!!!
Also, where can I find Turing on the internet for download? I've been working on it in class, which is a major reason I have as many questinos as I do..I didn't realize how much I sucked at it before I started attempting programs without teacher help lol..and we just got SWAMPED with assignments. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
PaulButler
![](http://compsci.ca/v3/uploads/user_avatars/60319641477fc8be91d94.jpg)
|
Posted: Wed Apr 11, 2007 4:47 pm Post subject: RE:A lot of questions... |
|
|
Since you posted this in general discussion, I don't know what language you are using.
The first question does not have enough information. Are you looking for how to close the program? This will depend on the language used.
For the second question, you just have to find where to split apart the strings. Again, this depends on the language you are using.
The third one is also simple string manipulation, find the first 6 alphanumeric characters in the string and uppercase them, then print them out with a space after the first 3. You can then check if the characters are in the right place.
Oh, so you are using Turing. It is commercial software so you won't be able to download it (legally) online. Since I haven't used Turing, I can't help you with the string manipulation. |
|
|
|
|
![](images/spacer.gif) |
Geostigma
|
Posted: Wed Apr 11, 2007 9:47 pm Post subject: Re: A lot of questions... |
|
|
K well Im assuming you know how to make the random number string right? Do you know what the "length" command does? it takes a string and counts it as 1..(x) so an example would be
number1:=length("jibbajibba") OR :=length("variable")
or its no brackets can't remember |
|
|
|
|
![](images/spacer.gif) |
ericfourfour
|
Posted: Wed Apr 11, 2007 10:36 pm Post subject: RE:A lot of questions... |
|
|
The length function simply returns the length of a string.
If you want to exit when the user wants to exit use this syntax:
That will exit the loop you are in. |
|
|
|
|
![](images/spacer.gif) |
Geostigma
|
Posted: Wed Apr 11, 2007 10:38 pm Post subject: RE:A lot of questions... |
|
|
What was the process turning strings to int. I know it works :s |
|
|
|
|
![](images/spacer.gif) |
ericfourfour
|
Posted: Wed Apr 11, 2007 10:47 pm Post subject: RE:A lot of questions... |
|
|
Geostigma, process is not really the correct word for what you are asking. Function is better. This is because a function returns a value. A process, starts a new thread and does not return a value.
The function that converts strings into integers is strint (most of the conversion functions in Turing follow that naming pattern). strint takes a string parameter, and returns the integer representation of it.
|
|
|
|
|
![](images/spacer.gif) |
Carey
![](http://mirkon.sneezepower.com/images/multilockon.gif)
|
Posted: Thu Apr 12, 2007 9:15 am Post subject: Re: A lot of questions... |
|
|
Heres a program I made to turn all the letters in a string to capitals. Should help you with your program.
Turing: |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Name: capitals
%Results: A string converted to capitals
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function capitals (words : string) : string
var capital := ""
for letters : 1 .. length (words )
if (ord (words (letters )) >= 97) and (ord (words (letters )) <= 122) then
capital + = chr (ord (words (letters )) - 32)
else
capital + = chr (ord (words (letters )))
end if
end for
result capital
end capitals
|
I originally used it in my file navigator program. find it here
-edit-
I think I made it. I might have found it somewhere though..... |
|
|
|
|
![](images/spacer.gif) |
Clayton
![](http://compsci.ca/v3/uploads/user_avatars/1718239683472e5c8d7e617.jpg)
|
Posted: Thu Apr 12, 2007 11:13 am Post subject: RE:A lot of questions... |
|
|
There's also the Str.Upper() function if you're interested ![Wink Wink](http://compsci.ca/v3/images/smiles/icon_wink.gif) |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Geostigma
|
Posted: Thu Apr 12, 2007 4:37 pm Post subject: Re: RE:A lot of questions... |
|
|
ericfourfour @ Wed Apr 11, 2007 10:47 pm wrote: Geostigma, process is not really the correct word for what you are asking. Function is better. This is because a function returns a value. A process, starts a new thread and does not return a value.
The function that converts strings into integers is strint (most of the conversion functions in Turing follow that naming pattern). strint takes a string parameter, and returns the integer representation of it.
I literally meant the process of doing something. |
|
|
|
|
![](images/spacer.gif) |
tenniscrazy
![](http://compsci.ca/v3/uploads/user_avatars/16168420744a9c16d226a1c.jpg)
|
Posted: Thu May 03, 2007 4:00 pm Post subject: RE:A lot of questions... |
|
|
for the first program tell the user that they have to type in something to exit the program, like 0, then after they input the varible which they use to guess the number put
exit when (var) = 0 |
|
|
|
|
![](images/spacer.gif) |
Carey
![](http://mirkon.sneezepower.com/images/multilockon.gif)
|
Posted: Fri May 04, 2007 8:47 am Post subject: Re: A lot of questions... |
|
|
@ Clayton: oops. I made it a while ago back when Turing didn't have Str.Upper() function. don't ridicule me! ![Crying or Very sad Crying or Very sad](http://compsci.ca/v3/images/smiles/icon_cry.gif) |
|
|
|
|
![](images/spacer.gif) |
|