Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

COMPUTER SCIENCE UNIT

KOLEJ MATRIKULASI PULAU PINANG

Individual Assignment SC025: Array


Instructions:

You must complete this assignment by yourself. You cannot work with anyone else in
the class or with someone outside of the class.

1. Choose ONE of the questions given below. For each question you need to

(a). Do a problem analysis


(b). Write an algorithm – Pseudocode AND Flowchart
(c). Write a full Java program

2. The assignment will be evaluated as given below:

(a). Problem Analysis – 10%


(b). Algorithm – 60%
(c). Coding – 30%

3. Due date : 28 Jan 2019

1
Question 1:

Koop KMPP Sdn. Bhd is doing an analysis of its 10 best sales representatives. The
analysis is important for the management to search for the best salesperson among
them. That particular salesperson will be awarded a token of appreciation from the
company. A computer program is required to assist the company in doing the
analysis. Write a complete Java program that prompt the user to enter salesperson’s
name, staff id, and their respective sales. Then a program read the input into the
corresponding arrays.

(a). Print salesperson’s staff id and the amount of sales in the format of a table.
(b). Print total sales and average sale.
(c). Print the salesperson Staff id with the highest sales.

Sample output:

Enter Staff ID: KP003


Enter Sale: RM473.00
Enter Staff ID: KP006
Enter Sale: RM765.00
Enter Staff ID: KM010
Enter Sale: RM231.00
Enter Staff ID: KP001
Enter Sale: RM678.00
.
.
.
Enter Staff ID: KP015
Enter Sale: RM983.00

LIST OF SALE BY STAFF

Num Staff ID Sales(RM)


1. KP003 473.00
2. KP006 765.00
3. KM010 231.00
.
.
9. KP007 550.00
10. KP015 983.00

Total Sale = RM5757.00


Average Sale= RM575.700
Highest Sale= RM925.00
Staff ID with the Highest Sale is KP015

2
Question 2:

During A Computer Science lecture session, a lecturer used Kahoot! It (online


education game based platform) to access the students understanding of topic
“Introduction to Java”. Write a Java program that will perform the following:

(a). Prompt number of participants and playerID for the game from user
(b). Find the total and average of score
(c). Find highest score
(d). Best player (playerID)

Sample Output:

3
Question 3:

YES.Fit VR Club will be handling a virtual run in February 2019. The organizer needs a
system to analyse records of the event should be stored in array. The organizer as a
user of the system needs to determine the number of runner per group before they
can record the total distance for each runner. The output of the analysis will help
them to identify the highest and lowest distance and respective runner ID, the total
distance and average distance. The output of the system are as follows:

(a). Prompt a user to enter the number of runner.


(b). Input runner ID and distance run for each runner. (distance in kilometre)
(c). System can display all the records entered by the organizer, The highest run
distance and respective runner ID, The lowest run distance and respective
runner ID. Besides, system also able to display accumulated run distance and
average run distance for the group.

SAMPLE OUTPUT:

4
Question 4:

Write a complete Java Program to determine the month of highest rainfall reading
and average rainfall for one year at Cameron Highlands. Prompt user to enter month
and rainfall for 12 months, then display the month with the highest rainfall, the highest
and average rainfall reading.

Sample Output

5
Question 5:

Malaysian Meteorology Department has collected total temperature for each of 12


months (Celcius) and stores into an array of doubles. Write a Java program that will
output the following:

• the total temperature for the year


• the average monthly temperature
• the month with the highest temperature

Sample output:

Enter your month and temperature:


Jan
38
Enter your month and temperature:
Feb
33
Enter your month and temperature:
Mac
30
.
.
.
Enter your month and temperature:
Dis
36

The total temperature for 12 months is: 400


The average temperature is: 38.9
The highest month of temperature is April with the temperature of 39

6
Question 6:

The haze phenomenon has hit Malaysia in June 2013. Schools, the government and
private sectors, have all been badly hit by closures or their employees who get in
medical leave. The quality of air is measured using the Air Pollutant Index (API) reading
and status for a particular district. Mr. Razak Husin, the managing director of Sulaiman
& Ahmad Co., a company located in X city, has directed you to update API reading
for 10 main districts.
Prompt user to enter district’s name and their API reading. Then a program read the
input into the corresponding arrays. Write a complete Java program to do the
following:

(a). Print district’s name and API reading in the format of a table.
(b). Print total API and average API.
(c). Prints the district’s name with the highest API.

Sample Output:

7
Attachment 1

COMPUTER SCIENCE 2 (SC025)


INDIVIDUAL ASSIGNMENT

ARRAY

NAME:
MATRIC NUMBER:
PRACTICUM CLASS:
LECTURER’S NAME:
QUESTION NO:
Copy your question here!

You might also like