0% found this document useful (0 votes)
42 views

Assignment Array (Syafiqah Batrisyia)

This document describes a Java program that stores customer order data in an integer array and allows the user to search for orders. The program stores the number of boxes ordered by 10 customers in an array. It then prompts the user to enter an order to search for and checks if it is in the array. If found, it displays a message and the index; if not found, it displays a message. Pseudocode and a flowchart are provided to design the solution. The document also discusses implementing, testing, and referencing the program.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views

Assignment Array (Syafiqah Batrisyia)

This document describes a Java program that stores customer order data in an integer array and allows the user to search for orders. The program stores the number of boxes ordered by 10 customers in an array. It then prompts the user to enter an order to search for and checks if it is in the array. If found, it displays a message and the index; if not found, it displays a message. Pseudocode and a flowchart are provided to design the solution. The document also discusses implementing, testing, and referencing the program.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

SC025 COMPUTER SCIENCE 2

3.0 Java Language


3.4 Array

NAME OF THE STUDENT : SYAFIQAH BATRISYIA BT MOHD ZAHIR


MATRIC NUMBER : MS2018175907
CLASS : DST27
NAME OF THE LECTURER : MADAM MARZITA BINTI ISMAIL
DATE OF SUBMISSION : 14 APRIL 2022
TABLE OF CONTENTS
INTRODUCTION………………………………………………………………………………………………………………………………….2
PROBLEM STATEMENT3........................................................................................................................3
PROBLEM ANALYSIS...............................................................................................................................4
DESIGN A SOLUTION
Pseudocode.......................................................................................................................................5
Flowchart...........................................................................................................................................6
IMPLEMENTATION.................................................................................................................................7
TESTING.................................................................................................................................................8
REFERENCES..........................................................................................................................................9

Page 1 of 9
INTRODUCTION

Problem solving is defined as the process of formulating a problem, finding a


solution, and expressing the solution. The five steps in problem solving are problem
analysis, design a solution, implementation, testing and documentation. Problem
analysis is an analysis of a problem statement to identify input, process and output.
Design a solution involves creating an algorithm that can be represented using
pseudocode and flowchart.

Page 2 of 9
PROBLEM STATEMENT

A program will store number of boxes ordered by 10 Harum Manis customer’s in an


integer type array: numBox[]. The data stored are as follows:

Inde Number of boxes


x
[0] 3
[1] 2
[2] 6
[3] 4
[4] 2
[5] 1
[6] 3
[7] 1
[8] 2
[9] 4

This program also allows user to retrieve the saved data. User will enter the keyword
(numBox) 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.

Page 3 of 9
PROBLEM ANALYSIS
Input : searchBox

Process : To determine whether the searchBox entered by user in the array based on the number
of boxes is found or not found. Repeat 10 times until the element of searchBox is found
and display the appropriate message and the index of the element. If the element of
searchBox is not found, display appropriate message.

Output : Message “Your order is found” and index of found element or message “Sorry, your
order is not found “.

Page 4 of 9
DESIGN A SOLUTION
Pseudocode

Start
numBox [ ] ={3, 2, 6, 4, 2, 1, 3, 1, 2, 4}
searchBox=0
i=0, found=false
while (i < 10)
if (searchBox = = numBox [i])
Print “Your order found in index: “
found = true
endif
i=i+1
endwhile
if (found = = false)
Print “Sorry, your order is not found.”
else
Print “Your order is found.”
endif
Stop

Page 5 of 9
Flowchart

Start

numBox []={3,2,6,4,2,1,3,1,2,4}

i=0
found = true
searchBox=0

found == Print “Sorry, your


i < 10 false order is not
F T found”
T

F
searchBox
Print “Your
==numBox[i]
order is found”

Print “Your order found in


Stop
index: “

found = true

i=i+1

Page 6 of 9
IMPLEMENTATION & DOCUMENTATION

Page 7 of 9
TESTING
Sample Output
a. Searching for Number of Box (Searching is not found)

b. Searching for Number of Box (Number of Found: 1)

c. Searching for Number of Box (Number of Found: 2)

d. Searching for Number of Box (Number of Found: 3)

Page 8 of 9
REFERENCES

Amran, M., & Marziah, M. Z. (2022). PROBLEM SOLVING USING JAVA LEARN BY EXAMPLE
(4th ed.).

w3resource. (2011, February 7). C++ Array: Exercises, Practice, Solution.


https://www.w3resource.com/cpp-exercises/array/index.php

Victoria University. (2022, March 31). APA 7th Referencing:Books.


https://libraryguides.vu.edu.au/apa-referencing/7Books

Page 9 of 9

You might also like