Professional Documents
Culture Documents
SSK3100 - SET A - 5
SSK3100 - SET A - 5
ONLINE TEST
SET A : QUESTION 5
FINAL EXAMINATION
FIRST SEMESTER 2020/2021
CODE : SSK3100
INSTRUCTIONS :
1. This paper consists of ONE (1) question.
2. Answer all the questions.
3. The full mark for this paper is 40 marks.
1
SSK3100_Final (A)_First Semester 2020/2021_Question 5 Matric Number:____________
Anda dikehendaki menulis satu atur cara untuk mengira bilangan elemen di dalam
satu senarai nombor perpuluhan yang mempunyai nilai lebih besar daripada nilai
purata nombor perpuluhan tersebut. Untuk menyelesaikan masalah ini, anda perlu
menulis metod-metod berikut:
1) metod readNumOfElem(input) meminta pengguna memasukkan bilangan
nombor perpuluhan yang akan diterima oleh atur cara melalui konsol. Metod ini
menerima pemboleh ubah rujukan bernama input untuk tujuan membaca
bilangan tersebut. Metod ini memulangkan bilangan nombor perpuluhan
tersebut.
2
SSK3100_Final (A)_First Semester 2020/2021_Question 5 Matric Number:____________
[CPS4][20M]
You are required to write a program to count the quantity of elements in a list of
floating-point numbers that is larger than the average value of the floating-point
numbers. To solve this problem, you need to write the following methods:
1) readNumOfElem(input) – the method asks the user to enter the quantity of
floating-point numbers via console. This method receives a reference variable
named input for the purpose of reading the quantity. This method returns the
quantity of floating-point numbers.
2) readNumbers(input,numOfElem) - the method asks the user to enter
floating-point numbers that will be stored in an array. The length of the array is the
same value as the quantity of floating-point numbers which is numOfElem. This
method receives a reference variable named input for reading the floating-point
numbers. This method returns the array filled with the floating-point numbers
inputted.
3) calcAverage(numArray) - the method calculates the average of the floating-point
numbers in numArray array. This method returns the average.
4) countAboveAverage(numArray, average) - the method counts the number of
elements in numArray array greater than the average value. This method returns
the number of elements.
5) printResult(average,count) – the method displays the following output values for
the average and the number of elements greater than average :
Jawapan/Answer: