Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Support

    3. Suggestions

Happy Holidays from the GTANet team!

Help with Turing programming!


Kaj.
 Share

Recommended Posts

Well, I am currently in a computer engineering course for school, and we're using Turing to program with. I hate Turing, with a passion. But I need to get this assignment done by Tuesday, and I've only got about 1/4 of the programs done. It's not that I've been goofing off during class, I just don't have a good grasp on this programming language.

 

If anyone can help me, please do, I need it desperately.

 

Add my MSN if you can be of assistance. [email protected]

 

This what I have left of the assignment-

 

 

 

Assignment 7:

 

Write a program that inputs a first name and a last name then outputs this in the form: lastname, firstname. Use only one “get” command!

 

Assignment 8:

 

Write a program to find the slope of a line when two points (X1,Y1) and (X2,Y2) are entered by the user. (You may have to input all four values separately.)

 

 

Assignment 9:

 

Pi can be calculated by adding up a certain series of numbers. Write a program to find pi using the following formula:

pi =

The program should print the results of using (a) three fractions, (b) six fractions, and © nine fractions.

 

Turing Mini-Assignments

 

 

LOOPs

 

Assignment 10:

 

Write a program containing an infinite loop that outputs the series of integers starting at 5 and going up by 5s. (Remember press ctrl-break to stop the program.)

 

Assignment 11:

 

Write a program that says “Hello!” six times then endlessly tells you to “Have a good day”.

 

Assignment 12:

 

Every character on the computer is assigned a number between 0 and 255. This is called the ASCII code. Character 57, for example, is the digit 9 and can be displayed with:

put chr(57)

Many of the characters with values from 0 to 13 are non-printing characters, that is, they will not display anything on the screen. Use a loop and chr() to display all of the printable characters.

 

Assignment 13:

 

Write a program that reads words (only one per line) and counts how many words have been entered before you give the signal word “end” to stop execution of the program. Experiment to determine what happens if you put several words on a line.

 

Assignment 14:

 

A series of marks is to be entered and averaged. Before the user enters the series, the program must ask how many marks there are in the series. It should then read in the marks. Test your program to see that it works for series of different lengths (e.g. four marks or six marks).

 

Assignment 15:

 

Write a program that announces at each repetition of a loop the number of times it has executed the loop. Have it stop at each execution with the message “Type ‘more’ to continue”. A sample output screen could be:

Loop execution number 1

Type ‘more’ to continue

more  user input

Loop execution number 2

Type ‘more’ to continue

 

Assignment 16:

 

Write a program to output a table of values and their squares endlessly. Label the columns at the top of the table. E.g.:

Number Square

1 1

2 4

3 9

4 16

5 25

 

Try to format the output so that it looks nice. What happens as the numbers get larger and larger? Change the program so that it only outputs the first 100 integers rather than going on forever.

 

Assignment 17:

 

Write a program to print the seven times table from 1 to 12 using a loop. The output should look like this:

1 x 7 = 7

2 x 7 = 14

3 x 7 = 21

4 x 7 = 28

etc.

 

Assignment 18:

 

Write a program using a loop counting backwards. Output the index of the loop on each execution so the output is the same as the countdown for a rocket launch. Arrange the output so that it is all on one line like this: 5 4 3 2 1

 

Assignment 19:

 

Write a program to calculate the value of pi using the expansion:

pi =

Inside your loop, you will need several variables:

a counter to count 1, 2, 3, 4, …

(e.g. count)

a variable for the terms 1/1**2, 1/2**2, 1/3**2, 1/4**2, …

(e.g. term)

a variable for the sum of the terms (1/1**2+1/2**2+1/3**2+ …)

(e.g. sum)

Pi can then be found from: pi = sqrt(6 * sum)

 

Exit the loop when pi exceeds 3.14 (i.e. it is accurate to 2 decimal places). Print the number of iterations through the loop it took to find pi this accurately (i.e. the value of your counter after the end of the loop). It should take about 600 iterations! This is a very slow way of finding pi accurately!!

 

Assignment 20:

 

Write a program to compute the bank balance at the end of each year for 10 years resulting from an initial deposit of $1000 and an annual interest rate of 9%. For each year-end, output the number of the year, the initial balance, the interest for the year, and the balance at the end of the year. The first couple of lines should look like:

Initial Interest Balance

1000.00 90.00 1090.00

1090.00 98.10 1188.10

 

Assignment 21:

 

Write a program to simulate the playing of a simple dice game (played with one die). Roll the die to get a value from 1 to 6. This we will call your point. Now keep rolling until you get the same value (your point) again and see how many rolls it takes. Program it so that you can play this game repeatedly.

 

IF Statements (conditions)

 

Assignment 22:

 

Write a program to generate a random “person” by randomly picking some attributes about the person and displaying them out. Your program should output something like this:

Sex: Female

Height (cm): 168

Weight (kg): 72

Hair colour: Sandy

Eye colour: Brown

 

Your program will need to generate several different random numbers … even the sex, hair and eye color will be random numbers. You will need some IF … THEN statements to take the random numbers and show the desired results (like Male or Female). Here are some ideas for values:

 

Sex: Male or Female

Height: 150 – 200 cm

Weight: 60 – 100 kg

Hair colours: blonde, brown, black, red, sandy, etc.

Eye colours: brown, blue, green, hazel, grey, etc.

 

Assignment 23:

 

Write a program to simulate (very simply!) playing golf. The hole is 100 yards away. Tell the player how far they are from the hole and tell them to press a key to take a shot. Now pick a random number from 1 to whatever the distance is (this is how far they shoot). Tell the player how far they shot, and then subtract this from the distance. Repeat this until the distance less than or equal to 1 yard.

Assignment 24:

 

Write a program to simulate a simple game of Blackjack. In Blackjack, you and the dealer draw cards from a deck. You try to get a total closer to 21 than the dealer without going over. Ace is low and all face cards count as 10. If you go over 21, you lose. If the dealer goes over 21, you win. Otherwise, if you get closer to 21 than the dealer, you win. (You lose if it is tied.)

 

To start your program, simulate the dealer drawing two cards. For simplicity, just pick random numbers from 1 to 10. Create a variable for the dealer’s total. If the dealer’s total is less than 15, pick another card and add it to the total. If the total is over 21, print that the player wins and end the program.

 

Assignment 25:

 

Add to assignment 24 a section that allows the player to play. You should give the player one card initially, then ask if they want to draw another card, and loop until they say “no”. Each time the player draws a card, pick a random number (1 to 10) and add it to the player’s total. After the end of the loop, you will need to see if the player went over 21 (and say “you lose”), or if the player’s total was higher than the dealer’s total (saying “you win” or “you lose” as appropriate), or if it was a tie (the dealer wins).

 

 

 

NOTE: The assignment sheet was done up in MS Word, so some of the sub/super-scripts don't show up. If you need the sheet, I can send it to you.

 

 

 

Any help would be greatly appreciated, honestly, you have no idea.

user posted image
Link to comment
Share on other sites

LMFAO!!!

 

WELCOME TO THE WORLD OF TURING, B*TCH! I just got over that sh*t a little while ago. Most of the assignments you have are damn easy - the end project stuff we had included programming a full game and making binary/hex/digit converters - amongst other things.

 

Here's the A7 one, just because I'm too lazy to help you with the other big ones:

 

Assignment 7:

 

Write a program that inputs a first name and a last name then outputs this in the form: lastname, firstname. Use only one “get” command!

 

 

% Input Variablesvar firstname, lastname : string% Operation codeput "Enter first name: " ..get firstnameput "Enter last name: " ..get lastnameput lastname ,", ", firstname

 

 

It'll look like this afterwards:

 

user posted image

 

 

I'll pop back in here and add more when I can. I'm just lazy - which is why I nearly flopped the course with a B-. wow.gif

 

 

Though, all in all, I should suggest that you go to your teacher with your concerns - rather than asking for help/free answers here. Your teacher's job is to help you with this sort of stuff.

zUd3j4P.png

Link to comment
Share on other sites

% Input Variablesvar firstname, lastname : string% Operation codeput "Enter first name: " ..get firstnameput "Enter last name: " ..get lastnameput lastname ,", ", firstname

 

 

Use only one “get” command!

"You can play faster than Al Di Meola and do it with only one pinky, but if you're not listening to what is going on around you, you might as well just shut up"

 

isn't your croth suppose to be erecting when you have an orgasm?
Link to comment
Share on other sites

And I was expecting the thread to be about the Turing Machine programming.

 

Anyways, most interpreter languages are very similar in design, and unless you actually need a script, they are a waste of time. Why don't they teach you something useful, like x86 ASM?

Prior to filing a bug against any of my code, please consider this response to common concerns.

Link to comment
Share on other sites

And I was expecting the thread to be about the Turing Machine programming.

 

Anyways, most interpreter languages are very similar in design, and unless you actually need a script, they are a waste of time. Why don't they teach you something useful, like x86 ASM?

That's the same thing I asked my teacher. But, I guess we need it for later in the course (for robotics) because it can control the parallel ports.

 

@Tsuroki, I could've done that one easily, but the "use only one 'get' command" is what f*cked me over. And I did ask me teacher (well, student teacher, our actual teacher is working with the grade 11's) and he's being a cock. He said we should learn it ourselves, and when I have a problem with it, he just says "yeah, you do have a problem. But you'll figure it out eventually". He's rather useless, and this assignment is due on Tuesday (it's flexible, but not by too much) and it's the weekend, so I can't contact him for help, and even if I did, he wouldn't really help me. And I'm not looking for free answers, I was looking for some one-on-one help over MSN while I was actually working on it.

user posted image
Link to comment
Share on other sites

And I was expecting the thread to be about the Turing Machine programming.

 

Anyways, most interpreter languages are very similar in design, and unless you actually need a script, they are a waste of time. Why don't they teach you something useful, like x86 ASM?

That's the same thing I asked my teacher. But, I guess we need it for later in the course (for robotics) because it can control the parallel ports.

 

@Tsuroki, I could've done that one easily, but the "use only one 'get' command" is what f*cked me over. And I did ask me teacher (well, student teacher, our actual teacher is working with the grade 11's) and he's being a cock. He said we should learn it ourselves, and when I have a problem with it, he just says "yeah, you do have a problem. But you'll figure it out eventually". He's rather useless, and this assignment is due on Tuesday (it's flexible, but not by too much) and it's the weekend, so I can't contact him for help, and even if I did, he wouldn't really help me. And I'm not looking for free answers, I was looking for some one-on-one help over MSN while I was actually working on it.

Oh sh*t, only one get command? wow.gif

 

And if you guys are controlling ports with Turing and such, thats above and beyond what I ever did. tounge.gif

 

As for the "use only one get command"... meh...

 

 

var: first, last : stringput "Enter firstname and lastname: " ..get first, lastput last ,", ", first

 

 

or something.

zUd3j4P.png

Link to comment
Share on other sites

We're not quite into the robotics unit yet, but when we do, we're supposed to use Turing to program a 3 wheeled robot. I'm not sure what we're (students) going to make the robots do, but the teacher says it's possible to program it in a way so it'll follow black lines on the floor, and identify and avoid obstacles like walls and stuff.

 

And thanks for the help with #7, but if you could catch me on MSN or something and help me a bit more, like, walk me through a few, without just giving me the answer, that'd be awesome.

user posted image
Link to comment
Share on other sites

That's a silly way to go about it. First of all, just about any computer language can communicate via parallel port, so it isn't a good reason. Furthermore, the very idea of having a robot controlled by a PC via a parallel port is ridiculous. A robot simple enough to be manipulated through a parallel port can function on something a lot simplier than a PC, and a robot that can utilize full power of a PC will require a much better connection. A much better example and work experience for students is to have a robot with an on-board CPU and programed on its native Assembley language or actual machine code. The parts required to convert the parallel port controlled robot into a fully autonomous one cost next to nothing if you use a cheap processor. An 8 bit micro controller would be sufficient, and it would make the opcodes easy to learn.

 

If that's still too advanced, the most basic solution is to use Lego Mindstorms. Yes, I said Lego. They have a brick called RCX which is a simple computer equiped with 3 motor output ports, 3 sensor input ports, and an infrared communication port. One of the sensors they have is a light sensor, and it can easily be used to make a robot that follows black lines on the floor. Of course, the programming software that comes with it is made for kids and is fairly useless. However, there is a special compiler for a variation of C, called NQC, which you can use to program the RCX brick, and that allows you to do everything you'd be able to do with Turing and a lot more.

Prior to filing a bug against any of my code, please consider this response to common concerns.

Link to comment
Share on other sites

I took TIK 2O1 last semester, and I loved Turing (rather, I liked it and hated VB and Flash, which we also used). I can probably help you out with most of your problems, but I don't do MSN. I'm on sysnode IRC a lot, though. Go use our Java client (no registration/etc required) and ask for gabriel.

 

I can't just tell you what to do for all your problems, but for #7 here's what I would do:

1) get the one name string

2) find the space in the string (I think the function for this is index)

3) use substrings to print the post-space part of the string, then ", ", then the pre-space part

Edited by Edwards

sysnode.org

Link to comment
Share on other sites

I took TIK 2O1 last semester, and I loved Turing (rather, I liked it and hated VB and Flash, which we also used). I can probably help you out with most of your problems, but I don't do MSN. I'm on sysnode IRC a lot, though. Go use our Java client (no registration/etc required) and ask for gabriel.

 

I can't just tell you what to do for all your problems, but for #7 here's what I would do:

1) get the one name string

2) find the space in the string (I think the function for this is index)

3) use substrings to print the post-space part of the string, then ", ", then the pre-space part

And this, my friends, is why I hate programming. It blows my symplistic visual-pattern-based mind.

zUd3j4P.png

Link to comment
Share on other sites

Thanks Ed, I should be talking to you later. And Tsuroki, I knwo exactly ahere you're coming from. (I think) you and Ed posted the same thing, but I have no idea how to use Ed's.
user posted image
Link to comment
Share on other sites

Thanks Ed, I should be talking to you later. And Tsuroki, I knwo exactly ahere you're coming from. (I think) you and Ed posted the same thing, but I have no idea how to use Ed's.

They are not at all the same thing, and Edwards' solution is the right one. You have to get the entire string consisting of first name, space, last name into a single variable, and then split it up by finding the space in the string.

Prior to filing a bug against any of my code, please consider this response to common concerns.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.