ok so for class I'm supposed to Write a class DeleteElements that prints out an array and asks the user which number should be
deleted and then deletes that number, if it exists from the array.
the first part tells me to
Step 1
o Start by simply searching the element.
o Pseudocode:
Create an array and populate it with random positive integers.
Print the array to show the user which elements the array contains.
Use a WHILE loop to search the element—a WHILE loop is better than a FOR
loop because you can stop when the element is found by using a Boolean
value in the loop condition—and also keep track of the location where the
element might be found.
If the element is not found, output the error message, “Number not found.”
Otherwise output the message, “Number found at index #.” where # is the index
where the element is.
Print out the array.
Example of output:
34 65 12 76 45 39 86 71 67
Number to delete: 76
Number found at index 3
this is what I've got so far but I can't seem to get the "number not found part to print out only once".
Current output result if value does not exist:
61 89 52 16 20 71 37 91 4 36
Number to delete:
23
Number not found.
Number not found.
Number not found.
Number not found.
Number not found.
Number not found.
Number not found.
Number not found.
Number not found.
Number not found.
Current output result if value exists:
97 48 51 22 89 5 42 97 43 96
Number to delete:
89
Number found at index 4
Maybe I'm not understanding the part about the boolean value.
I would appreciate all the help i could get.