From b557bdafb459ed98c4ffba18f74054e49dbbfc31 Mon Sep 17 00:00:00 2001 From: Baloyy Date: Fri, 28 Jun 2024 20:23:00 +0800 Subject: [PATCH] Create Flow chart Create a flowchart for my Pseudocode --- Flow chart | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Flow chart diff --git a/Flow chart b/Flow chart new file mode 100644 index 0000000..e29fc7f --- /dev/null +++ b/Flow chart @@ -0,0 +1,54 @@ +Initialize an array of names: ["Natsu", "Rimuru", "Tanjiro", "Asta", "Valentine"] +Display the array of names + +Loop indefinitely: + Display menu options: + 1 - Display Sorted + 2 - Display All Elements + 3 - Read ith Element + 4 - Replace ith Element + Prompt the user to select an option + + Read user's input + + Try: + If input is "1": + Call displaySorted function with the name array + + Else If input is "2": + Call displayAllElements function with the name array + + Else If input is "3": + Call readIndex function with the name array + Exit loop + + Else If input is "4": + Call replaceIndex function with the name array + + Else: + Display "Invalid Option Please Try Again!" + + Catch InputMismatchException: + Display "Invalid Option. Please Try Again!" + +Function displaySorted(name): + Copy name array to sortedName array + Sort sortedName array in ascending order + Print sorted name array + +Function displayAllElements(name): + For each element in name array: + Print the element + +Function readIndex(name): + Prompt user to enter an index + Read index from user + Print the element at the specified index + +Function replaceIndex(name): + Prompt user to enter an index + Read index from user + Prompt user to enter a new value + Read new value from user + Replace the element at the specified index with the new value + Print the updated name array