Question: I need this psuedocode in Flowgorithm program. The previous answer is in a flowchart which is different than FLOWGORITH. Pease use the following program to

I need this psuedocode in Flowgorithm program. The previous answer is in a flowchart which is different than FLOWGORITH. Pease use the following program to create the FLOWGORITHM.

Constance manages a cooking school that employees six instructors. She has asked you to design a program that she can use to look up an instructors phone number. You decide to use two parallel arrays: one named names that will hold the instructors last names, and another named phones that will hold each instructors phone number. Here is the general algorithm: 1. Get an instructors last name from the user. 2. Search for the name in the names array. 3. If the name is found, get its subscript. Use the subscript to display the contents of the parallel phones array. If the name is not found, display a message indicating so. Program 9-8 shows the pseudocode for the program. Note that the array contents are already sorted in ascending order. This is important because the program uses the binary search algorithm to locate a name in the names array.

1 Module main()

2 // Constant for array sizes

3 Constant Integer SIZE = 6

4

5 // Array of instructor names, already sorted in

6 // ascending order.

7 Declare String names[SIZE] = "Hall", "Harrison",

8 "Hoyle", "Kimura",

9 "Lopez", "Pike"

10

11 // Parallel array of instructor phone numbers.

12 Declare String phones[SIZE] = "555-6783", "555-0199",

13 "555-9974", "555-2377",

14 "555-7772", "555-1716"

15

16 // Variable to hold the last name to search for.

17 Declare String searchName

18

19 // Variable to hold the subscript of the name.

20 Declare Integer index

21

22 // Variable to control the loop.

23 Declare String again = "Y"

24

25 While (again == "Y" OR again == "y")

26 // Get the name to search for.

27 Display "Enter a last name to search for."

28 Input searchName

29

30 // Search for the last name.

31 index = binarySearch(names, searchName, SIZE)

32

33 If index 1 = -1 Then

34 // Display the phone number.

35 Display the phone number is ", phones [index]

36 Else

37 // the name was not found in the array.

38 Display searchName, "was nor found."

39 End If

40

41 // Search again?

42 Display "Do you want to search again? (Y=yes, N=No)"

43 Input again

44 end While

45

46 End Module

47 // This is for FUNCTION

48 // the binarySearch function accepts as arguments a String

49 // array, a value to search the array for, and the size

50 // of the array. If the value is found in the array, its

51 // subscript is returned. Otherwise, -1 is returned,

52 // indicating that the value was not found in the array.

53 Function Integer binarySearch(string array[], String value,

54 Integer arrayZize)

55 // Variable to hold the subscript of the first element.

56 declare Integer first = 0

57

58 // variable to hold the subscript of the least element.

59 Declare Integer last = arraySize - 1

60

61 //position of the search value

62 Declare Integer position = -1

63

64 // Flag

65 Declare Boolean found = False

66

67 // Variable to hold the subscript of the midpoint

68 declare Integer middle

69

70 While (NOT found) AND (first<= last)

71 // calculate the midpoint

72 Set middle = (first + last) / 2

73

74 /// see if the value is found at the midpoint.....

75 If array(middle) == value then

76 Set found = True

77 Set position = middle

78

79 // Else, if the value is in the lower half....

80 else if array(middle)> value Then

81 set last = middle - 1

82

83 // Else, if the value is in the upper half...

84 Else

85 Set first = middle + 1

86 End If

87 End While

89 // return the position of the item, or -1

90 // if the item was not found,

91 Return position

92 end Function

Program Output (with input Shown In Bold)

enter a last name to search for.

Lopez [Enter]

The phone number is 555-7772

Do you want to search again? (Y=yes, N=no)

Y[enter]

Enter a last name to search for.

Harrison [enter]

The phone number is 555-0199

Do you want to search again? IY=yes, N=No)

Y (Enter)

Enter a last name to search for ,

Lee (Enter)

lee was not found.

Do you want to search again (Y=yes, N=N0)

N[Enter]

I NEED ONLY FLOWGORITHM not just a flowchart please.

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!