How to resolve the algorithm Mad Libs step by step in the Applesoft BASIC programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Mad Libs step by step in the Applesoft BASIC programming language
Table of Contents
Problem Statement
Mad Libs is a phrasal template word game where one player prompts another for a list of words to substitute for blanks in a story, usually with funny results.
Write a program to create a Mad Libs like story. The program should read an arbitrary multiline story from input. The story will be terminated with a blank line. Then, find each replacement to be made within the story, ask the user for a word to replace it with, and make all the replacements. Stop when there are none left and print the final story.
The input should be an arbitrary story in the form:
Given this example, it should then ask for a name, a he or she and a noun (
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Mad Libs step by step in the Applesoft BASIC programming language
Source code in the applesoft programming language
100 DIM L$(100),W$(50),T$(50)
110 LET M$ = CHR$ (13)
120 FOR L = 1 TO 1E9
130 READ L$(L)
140 IF LEN (L$(L)) THEN NEXT L
150 FOR I = 1 TO L
160 LET M = 0
170 LET N$(0) = ""
180 FOR J = 1 TO LEN (L$(I))
190 LET C$ = MID$ (L$(I),J,1)
200 IF C$ = "<" AND NOT M THEN M = 1:C$ = "":N$(M) = ""
210 IF C$ = ">" AND M THEN GOSUB 300:M = 0:C$ = W$(Z)
220 LET N$(M) = N$(M) + C$
230 NEXT J
240 LET L$(I) = N$(0)
250 NEXT I
260 FOR I = 1 TO L
270 PRINT M$L$(I);
280 NEXT
290 END
300 FOR Z = 0 TO T
310 IF T$(Z) = N$(M) THEN RETURN
320 NEXT Z
330 LET T = Z
340 LET T$(Z) = N$(M)
350 PRINT M$"ENTER A "T$(Z);
360 INPUT "? ";W$(Z)
370 RETURN
380 DATA " WENT FOR A WALK IN THE PARK. "
390 DATA "FOUND A . DECIDED TO TAKE IT HOME."
990 DATA
You may also check:How to resolve the algorithm Safe primes and unsafe primes step by step in the Phix programming language
You may also check:How to resolve the algorithm Integer sequence step by step in the min programming language
You may also check:How to resolve the algorithm Statistics/Normal distribution step by step in the Rust programming language
You may also check:How to resolve the algorithm Jensen's Device step by step in the Oforth programming language
You may also check:How to resolve the algorithm Convert decimal number to rational step by step in the FreeBASIC programming language