QBasic String

Project 1

Top:
CLS
PRINT STRING$(25, “-“)
COLOR 2
PRINT TAB(10); “STRING MANIPULATION SYSTEM”
PRINT STRING$(25, “-“)
PRINT TAB(10); “Choices”, “Operations”
PRINT TAB(10); 1, “Check Palindrome Word”
PRINT TAB(10); 2, “Display Total Vowels and Consonants”
PRINT TAB(10); 3, “Display Reverse Word”
PRINT TAB(10); 4, “Display First Name Only”
PRINT TAB(10); 5, “Display Last Name Only”
PRINT TAB(10); 6, “Display new word removing Vowels”
INPUT “Enter your choice number (1/2/3/4/5/6)”; choice
SELECT CASE choice
CASE 1
REM to check palindrome word.
CLS
INPUT “Enter any Word”; A$
FOR i = LEN(A$) TO 1 STEP -1
B$ = B$ + MID$(A$, i, 1)
NEXT i
IF B$ = A$ THEN
PRINT A$; “=”; “It is palindrome”
ELSE
COLOR 2

PRINT A$; “=”; “it is not palindrome”
END IF
END

CASE 2
REM counts total number of vowels and consonants in a word.
CLS
INPUT “ENTER ANY STRING”; S$
FOR i = 1 TO LEN(S$)
B$ = MID$(S$, i, 1)
C$ = UCASE$(B$)
IF C$ = “A” OR C$ = “E” OR C$ = “I” OR C$ = “O” OR C$ = “U”THEN
V = V + 1

ELSE
C = C + 1
END IF
NEXT i
PRINT “TOTAL NO. OF VOWELS= “; V
PRINT “TOTAL NO. OF CONSONANTS”; C
END

CASE 3
REM to display reverse word.
CLS
INPUT “Enter a word”; W$
FOR j = 1 TO LEN(W$)
rev$ = MID$(W$, j, 1) + rev$
NEXT j
PRINT “Reverse word”; rev$
END

CASE 4
REM to display the first name only from the supplied word.
CLS
INPUT “Enter a full name:”; W$
FOR j = 1 TO LEN(W$)
E$ = MID$(W$, j, 1)
IF E$ <> ” ” THEN
New$ = New$ + E$
ELSE
EXIT FOR
END IF
NEXT j
PRINT “FIRST NAME is :”; New$
END

CASE 5
REM to display the last name only from the supplied word.
CLS
INPUT “Enter a full name:”; W$
FOR j = LEN(W$) TO 1 STEP -1
E$ = MID$(W$, j, 1)
IF E$ <> ” ” THEN
New$ = E$ + New$
ELSE
EXIT FOR
END IF
NEXT j
PRINT “LAST NAME is :”; New$
END

CASE 6
REM removes vowels characters from the supplied word.
CLS
INPUT “Enter a word:”; W$
FOR j = 1 TO LEN(W$)
E$ = UCASE$(MID$(W$, j, 1))
IF E$ <> “A” AND E$ <> “E” AND E$ <> “I” AND E$ <> “O” AND E$ <> “U” THEN
New$ = New$ + E$
END IF
NEXT j
PRINT “New word removing vowels is :”; New$
END

CASE ELSE
PRINT “INVALID CHOICE TRY AGAIN”
END SELECT
INPUT “DO you want to continue(YES or NO)”; C$
IF C$ = “Y” OR C$ = “y” OR C$ = “yes” OR C$ = “YES” THEN

GOTO Top
ELSE
PRINT “Thank You For Using This Program”
END IF
END