Question

Write a program to dimension an array with the statement DIM states$(1 TO 50) and maintain a list of certain US States


Using QBasic Programming


Write a program to dimension an array with the statement DIM states$(1 TO 50) and maintain a list of certain US States. The list of states should always be in alphabetical order and occupy consecutive elements of the array. The options for this menu-driven program should be as follows:


 (a) Request a state as input and insert it into its proper position in the array. (If the state is already in the array, so report)

 (b) Request a state as input and delete it from the array. (If the state is not in the array, so report)

 (c) Display the states in the array

 (d) Quit

1 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

DIM STATE$(50)

DIM STSES2$(50)

D0

PRINT("Select the option")

PRINT(" 1. Insert a State " , "2. Delete a State" ,"3. Display a State" , "4.Quit")

IF OPTION=1 THEN

PRINT(" Enter a State ")

INPUT NEWSTATE$

P=1

I=0

D=0

FOR A= 1 TO 50

IF STATE $(A) >NEWSTATE AND I=0 THEN

IF STATE (A)= NEW STATE THEN D=1

STATE 2$(P)=NEW STATE $

STATE 2$(P+1)=STSTE$(A)

P=P+2

I=1

ELSE

STATE 2$(P) = STATE $(A)

P=P+1

END IF

NEXT A

IF(D<>1) THEN

FOR A= 1 TO 50

STATE $(A)=STATE$(A)

NEXT A

ELSE

PRINT("This State is already exit")

ENDIF

ENDIF

IF OPTION=2 THEN

PRINT("Enter a State ")

INPUT NEW STATE$

F=0

P=1

FOR A=1 TO 50

IF STATE $(A)<> NEW STATE THEN

STATE 2$(P) = STATE $(A)

P=P+1

F=1

END IF

NEXT A

IF F=0 THEN

PRINT ("State is not found")

END IF

IF OPTION=3 THEN

FOR A =1 TO 50 STEP 5

PRINT STATE $(A);STATE $(A+1); STATE $(A+2); STATE$(A+3): STATE$(A+4)

NEXT A

ENDIF

IF OPTION=4 THEN CONTINUE=1

LOOP

WHILE CONTINUE=0

PRINT" "

Add a comment
Know the answer?
Add Answer to:
Write a program to dimension an array with the statement DIM states$(1 TO 50) and maintain a list of certain US States
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Assignment Write a menu-driven C++ program to manage a class roster of student names that can...

    Assignment Write a menu-driven C++ program to manage a class roster of student names that can grow and shrink dynamically. It should work something like this (user input highlighted in blue): Array size: 0, capacity: 2 MENU A Add a student D Delete a student L List all students Q Quit ...your choice: a[ENTER] Enter the student name to add: Jonas-Gunnar Iversen[ENTER] Array size: 1, capacity: 2 MENU A Add a student D Delete a student L List all students...

  • Write a menu-driven C++ program to manage a class roster of student names that can grow...

    Write a menu-driven C++ program to manage a class roster of student names that can grow and shrink dynamically. It should work something like this (user input highlighted in blue): Array size: 0, capacity: 2 MENU A Add a student D Delete a student L List all students Q Quit ...your choice: a[ENTER] Enter the student name to add: Jonas-Gunnar Iversen[ENTER] Array size: 1, capacity: 2 MENU A Add a student D Delete a student L List all students Q...

  • Write a simple todo list application. This will require use of classes, objects, and possibly structs....

    Write a simple todo list application. This will require use of classes, objects, and possibly structs. Here are the requirements: 1. Menu-driven - upon running the program, the user should be prompted to press one of the following: 1. View all Todos in list 2. Remove a todo item from the list * if there are not any todos, the user should be prompted and sent back to the menu * choose a todo from list based on title to...

  • 1. Write a program to input a list of names (strings) from the user and store...

    1. Write a program to input a list of names (strings) from the user and store them in an ArrayList. The input can be terminated by entering the empty string or by entering the string “quit”. 2. Add further functionality to your program so that it searches the ArrayList to find the first string and the last string according to dictionary ordering and then prints out these strings (names). Do this exercise without sorting the names in the ArrayList. For...

  • Assignment #2: List - Array Implementation Review pages 6-7 in "From Java to C++" notes. Due...

    Assignment #2: List - Array Implementation Review pages 6-7 in "From Java to C++" notes. Due Friday, February 9th, 2017 @ 11:59PM EST Directions Create a List object. Using the following definition (List.h file is also in the repository for your convenience) for a list, implement the member functions (methods) for the List class and store the implementation in a file called List.cpp. Use an array to implement the list. Write the client code (the main method and other non-class...

  • Can you help us!! Thank you! C++ Write a program that can be used by a...

    Can you help us!! Thank you! C++ Write a program that can be used by a small theater to sell tickets for performances. The program should display a screen that shows which seats are available and which are taken. Here is a list of tasks this program must perform • The theater's auditorium has 15 rows, with 30 seats in each row. A two dimensional array can be used to represent the seats. The seats array can be initialized with...

  • Write the following program in C++. Review structures, pointers and dynamic memory allocation from CSIT 839....

    Write the following program in C++. Review structures, pointers and dynamic memory allocation from CSIT 839. Also, review pointers and dynamic memory allocation posted here under Pages. For sorting, you can refer to the textbook for Co Sci 839 or google "C++ sort functions". I've also included under files, a sample C++ source file named sort_binsearch.cpp which gives an example of both sorting and binary search. The Bubble sort is the simplest. For binary search too, you can refer to...

  • Write a program that has an array of at most 50 strings that hold people’s names...

    Write a program that has an array of at most 50 strings that hold people’s names and phone numbers. You can assume each string’s length is no more than 40. You may make up your own strings, or use the following: "Becky Warren, 555-1223" "Joe Looney, 555-0097" "Geri Palmer, 555-8787" "Lynn Presnell, 555-1212" "Holly Gaddis, 555-8878" "Sam Wiggins, 555-0998" "Bob Kain, 555-8712" "Tim Haynes, 555-7676" "Warren Gaddis, 555-9037" "Jean James, 555-4939" "Ron Palmer, 555-2783" The program should ask the user...

  • Stuck on this computer science assignment Write a program that demonstrates binary searching through an array...

    Stuck on this computer science assignment Write a program that demonstrates binary searching through an array of strings and finding specific values in an corresponding parallel double array. In all cases your output should exactly match the provided solution.o. Provided files: Assignment.cpp - starter assignment with function prototypes companies.txt - file for program to read. earnings.txt - file for program to read. Input1.txt Input2.txt - Test these inputs out manually, or use stream redirection Input3.txt - These inputs are based...

  • (2 bookmarks) In JAVA You have been asked to write a program that can manage candidates...

    (2 bookmarks) In JAVA You have been asked to write a program that can manage candidates for an upcoming election. This program needs to allow the user to enter candidates and then record votes as they come in and then calculate results and determine the winner. This program will have three classes: Candidate, Results and ElectionApp Candidate Class: This class records the information for each candidate that is running for office. Instance variables: first name last name office they are...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT