|
Until you sign up you can't do much. Yes, it's free.
|
|
|
|
|
|
|
 | / / / Viewing Topic
|  |
( penguincube )
1839
Patron
|
I'm sure I'm not the first person to do this, but one day it just popped into my head to make MAD LIBS on QBASIC. It's really *really* easy to do and you can make someone laugh! | Code: | LIBS: CLS PRINT "Welcome to Mad Libs. Please type in a word that matches" PRINT "what I ask for, then we'll make a funny paragraph!" PRINT "" INPUT "Plural Noun"; liba$ INPUT "Colour"; libb$ INPUT "Plural Article of Clothing"; libc$ INPUT "Something you don't care about"; libd$ INPUT "A foreign country"; libe$ INPUT "Your last name"; libf$ PRINT "" PRINT "" PRINT "The Congress is made up of two houses: The Senate and the" PRINT "House of "; liba$; ". When Congress is in Session, they all wear" PRINT libb$; " "; libc$; " and they debate important issues, such as" PRINT libd$; ". They meet in "; libe$; " ,because their jobs were outsourced" PRINT "under President "; libf$ INPUT ""; anykey$ |
Also, in a program that I have to make for school, we have to use arrays. I know how to load data into arrays, bubble sort them, print them out and stuff, but I just don't want to make a program that is just like "Hey, this is an array. Type some numbers." Do you know have any creative or fun uses for arrays?
------- firman consensus facit
|
|
|
|
|
 LiveWire Humor
|
|
lacunacoil
Dairy Product Addict
|
righttt...
------- Change your signature. -Moderator
|
|
|
|
|
|
|
|
|
( penguincube )
1839
Patron
|
Here is how I used arrays, squirrel. It's a fun little game that I am actually quite proud of. I get it to generate a random number from 1-10 from the array, but the user has to guess it first. They win if they guess within 2 integers. The fun part is the user gets to wager how many points they want to risk on each of the 15 turns. But not more than they have!| Code: | TEST: CLS PRINT "This is a game of chance. The program will pick a RANDOM" PRINT "number between 1 - 10. Before the computer picks the number," PRINT "you will be asked to GUESS a number that IS WITHIN 2 INTIGERS" PRINT "from the random one." PRINT "Your score will be based on how well you guess." INPUT "STRIKE ANY KEY WHEN YOU ARE READY"; ANY$ RESTORE SCORE = 5 FOR X = 1 TO 10 CLS READ NUM(X) NEXT X DATA 1,2,3,4,5,6,7,8,9,10 FOR X = 1 TO 15 CLS RANDOMIZE TIMER RN = INT(RND * 9) + 1 PRINT "YOU HAVE "; SCORE; " POINTS." INPUT "HOW MANY POINTS WOULD YOU LIKE TO WAGER?"; WAG IF WAG > SCORE THEN GOTO POINTTILT INPUT "TAKE YOUR GUESS"; GUESS PRINT "" PRINT "YOU HAVE "; 15 - X; " TURNS REMAINING."IF GUESS = RN + 1 OR GUESS = RN + 2 OR GUESS = RN - 1 OR GUESS = RN - 2 THEN GOSUB RANDRIGHT IF GUESS < RN - 2 OR GUESS > RN + 2 THEN GOSUB RANDWRONG IF GUESS = RN THEN GOSUB RANDEXACT NEXT X RANDRIGHT: PRINT "" PRINT "" SCORE = SCORE + WAG PRINT "YOUR GUESS: "; GUESS PRINT "THE RANDOM NUMBER IS: "; RN PRINT "YOU GAINED "; WAG; " POINTS " PRINT "YOUR SCORE: "; SCORE SLEEP 4 RETURN RANDWRONG: PRINT "" PRINT "" SCORE = SCORE - WAG PRINT "YOUR GUESS: "; GUESS PRINT "THE RANDOM NUMBER IS: "; RN PRINT "YOU LOST "; WAG; " POINTS" PRINT "YOUR SCORE: "; SCORE SLEEP 4 RETURN RANDEXACT: PRINT "" PRINT "" BONUS = WAG + 3 SCORE = SCORE + BONUS PRINT "YOUR GUESS: "; GUESS PRINT "THE RANDOM NUMBER IS: "; RN PRINT "YOU GOT"; WAG; " POINTS, PLUS A 3 POINT BONUS!" PRINT "YOUR SCORE: "; SCORE SLEEP 4 RETURN POINTTILT: PRINT "YOU TRIED TO WAGER MORE POINTS THAN YOU HAVE!!!" SLEEP 3 RETURN |
------- firman consensus facit
|
|
|
squirellplayingtag
Dairy Product Addict
Patron
|
Awsome. That's the first time I've ever actually looked at basic code other then on my calculator. Can you return a value such as an integer? Like if X =5 could you do something like RETURN X? And is your array named DATA with 10 values?
------- "The most abundant element in the universe is hydrogen, then second is stupidity."-Harlan Ellison "What good fortune for our governments that the people do not think."-Hitler
|
|
|
( penguincube )
1839
Patron
|
My array is not named "DATA" my array is named "NUM"| Code: | FOR X = 1 TO 10 CLS READ NUM(X) |
NUM is the name of the array. The "DATA" you saw comes into play with the READ command up there. It says for X = 1 to 10 READ the data. It reads the first ten numbers in my DATA line, which happen to be 1-10 | Code: | | DATA 1,2,3,4,5,6,7,8,9,10 |
So, when X = 1, it loaded 1 into NUM(1), when X = 2, it loaded 2 into NUM(2), and so on, until the ten numbers from my DATA line were in my array....called NUM I'm not sure I understand the other part of your question. By "when X = 5" do you mean the fifth time the loop "For x = 1 to 10?" Like: | Code: | FOR X = 1 to 10 PRINT X NEXT X |
That would print the numbers 1-10 on the screen. Clarify what you meant.I'll miss this class :p I get to take C++ next year though so yay.
------- firman consensus facit
|
|
|
|
|
( penguincube )
1839
Patron
|
What does RETURN --do-- in java? The only thing I know that command for in BASIC is to go back to were you started after you execute a subroutine, like in my program above. Maybe what RETURN does in java is called something else in basic?
------- firman consensus facit
|
|
|
|
|
( penguincube )
1839
Patron
|
How do you get a string on the TI-83+? I couldn't find $ or anything. I only fiddled with it for a minute during math class but it looks different from QBASIC...doesn't it use display or something instead of "Print?"
------- firman consensus facit
|
|
|
|
|
|
| Looking for something else?
|
|
|
|
|
|
 | / / / Viewing Topic |  |
|