ARRAY ASSIGNMENT
ARRAY ASSIGNMENT
TITLE : ARRAY
MATRIC NO : MS2118122500
PRACTICUM : DFT39
1
Table of Content
2
s
1.0 Problem Statement........................................................................................................................3
2.0 Problem Analysis (IPO)...................................................................................................................4
3.0 Design A Solution............................................................................................................................5
3.1 Pseudocode.................................................................................................................................5
3.2 Flowchart.....................................................................................................................................6
4.0 Implementation & Documentation................................................................................................7
5.0 Testing............................................................................................................................................8
REFERENCES........................................................................................................................................12
3
1.0 Problem Statement
A program will receive inputs from the user and save them in a String type array;
bookID[]. The minimum data to be saved is ten (10).
This program also allows user to retrieve the saved data. User will enter the keyword
(bookID) to be searched in the array.
The program then will display the following information:
- an appropriate message if the element is found
- the index of found element
- an appropriate message if the element is not found.
4
2.0 Problem Analysis (IPO)
Input : bookID,keyword
Process : -Create and declare an array for bookID.
-Repeat input bookID into the array for 10 times.
-Input keyword and repeat compare element 10 times.
-Display message ”The book is FOUND!”and ” is present at index ”
or “The book is NOT FOUND!” based on keyword.
5
3.0 Design A Solution
3.1 Pseudocode
Start
int i=0
read bookID[]
i++
endfor
Read keyword
initialize found=false
int i=0
if(keyword.equals(bookID[]))
found=true
Print bookID[],index
endif
i++
endfor
if(found==false)
endif
End
6
3.2 Flowchart
Start
int i=0
False
int i=0
True
i<bookID.length
True
i++ i++
False
found==false search.equals(bookID[i])
False
True True
7
4.0 Implementation & Documentation
8
5.0 Testing
First Output
----jGRASP exec: java ArrayBookID
Enter the BookID 1:A1
Enter the BookID 2:A2
Enter the BookID 3:A3
Enter the BookID 4:A4
Enter the BookID 5:A5
Enter the BookID 6:A6
Enter the BookID 7:A7
Enter the BookID 8:A8
Enter the BookID 9:A9 Enter
the BookID 10:A10
Enter BookID to search :
A5
The book is FOUND!
A5 is present at index 4
----jGRASP: operation complete.
Figure 1.Output1
9
----jGRASP: operation complete.
Second Output
Figure 2.Output2
10
Third Output
----jGRASP exec: java ArrayBookID
Enter the BookID 1:A1
Enter the BookID 2:A2
Enter the BookID 3:A3
Enter the BookID 4:A4
Enter the BookID 5:A5
Enter the BookID 6:A6
Enter the BookID 7:A7
Enter the BookID 8:A8
Enter the BookID 9:A9 Enter
the BookID 10:A10
Enter BookID to search :
A15
The book is NOT FOUND!
----jGRASP: operation complete.
Figure 3.Output3
11
Fourth Output
----jGRASP exec: java ArrayBookID
Enter the BookID 1:A1
Enter the BookID 2:A2
Enter the BookID 3:A3
Enter the BookID 4:A4
Enter the BookID 5:A5
Enter the BookID 6:A6
Enter the BookID 7:A7
Enter the BookID 8:A8
Enter the BookID 9:A9 Enter
the BookID 10:A10
Enter BookID to search :
A20
The book is NOT FOUND!
----jGRASP: operation complete.
Figure 4.Output4
12
REFERENCES
Hermansen , C. (2019, October 22). Initializing arrays in Java. Opensource.com. Retrieved
April 6, 2022, from https://opensource.com/article/19/10/initializing-arrays-java
Iyer, A. (2019, May 22). Java array tutorial: Single & Multi Dimensional Arrays in Java.
Edureka. Retrieved April 6, 2022, from https://www.edureka.co/blog/java-array/
Md Ali, M. A., & Mohd Zain, M. (2022). Problem Solving Using Java. Fourth published.
Nam, H. M. (2019, August 21). Array Java Programming. Notes about arrays in Java.
Retrieved April 6, 2022, from https://www.codejava.net/java-core/the-java-++++
Vincent Abba, I. (2022, February 4). Java array – how to declare and initialize an array in
Java example. freeCodeCamp.org. Retrieved April 6, 2022, from
https://www.freecodecamp.org/news/java-array-how-to-declare-and-initialize-an-
arrayin-java-example/
13