Question: 1. Write a pseudocode declaration for a String array initialized with the following strings: Emma, Ayantu, Luis, and Jordan. 2. Assume names is an Integer

1. Write a pseudocode declaration for a String array initialized with the following strings: "Emma", "Ayantu", "Luis", and "Jordan".

2. Assume names is an Integer array with 20 elements. Design a For loop that displays each element of the array.

3. Assume the arrays numberArray1 and numberArray2 each have 100 elements. Design an algorithm that copies the values in numberArray1 to numberArray2. Write your algorithm in pseudocode.

4. Explain the error in the pseudocode below? Write a working Python program, take a screenshot of the code and output and copy into your answer document.

// This program uses an array to display five names.

Constant Integer SIZE = 5

Declare String names[SIZE] = "Meg", "Jack", "Steve",

"Bill", "Lisa"

Declare Integer index

For index = 0 To SIZE

Display names[index]

End For

5. Describe the error in the pseudocode below?. Write a working Python program, including the main() module, take a screenshot of the code and output and copy into your answer document.

// This function returns the index of value, or -1 if not found

Function Integer findValue(Integer nums[], Integer size, Integer value)

Declare Integer index

For index = 0 To size 1

If nums[index] == value Then

Return index

Else

Return -1

End If

End For

End Function

6. The pseudocode below creates an array with 6 names, prompts the user for a name to search for, and displays a message with the index where the name was found, or a message if it was not found in the array. Write a working Python program from the pseudocode below - your program should be case insensitive, meaning Sally and SALLY will be found in the list below. Copy a screenshot of your code and console window output into your answer document.

// Declare a constant for the array size.

Constant Integer SIZE = 6

// Declare a String array initialized with values.

Declare String names[SIZE] = "Sally", "Tom",

"Sameer", "Rishika",

"Fernando", "Camilio"

// Declare a variable to hold the search value.

Declare String searchValue

// Declare a Boolean variable to act as a flag.

Declare Boolean found

// Declare a counter variable for the array.

Declare Integer index

// The flag must initially be set to False.

Set found = False

// Set the counter variable to 0.

Set index = 0

// Get the string to search for.

Display "Enter a name to search for in the array."

Input searchValue

// Step through the array searching for

// the specified name.

While found == False AND index <= SIZE 1

If names[index] == searchValue Then

Set found = True

Else

Set index = index + 1

End If

End While

// Display the search results.

If found Then

Display "That name was found at subscript ", index

Else

Display "That name was not found in the array."

End If

7. Refactor (modify without changing the functionality) the program you wrote for question #6 to use modules. Your program should continue asking the user for names until they are done. Use the high level design below as a guide, there are many different ways to implement the functionality - I want to see how YOU think about breaking down the problem:

main()

create array of names

while user wants to search

name = promptForName()

if name is in array

print message with index

else

print message not found

prompt user if they want to search again

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!