You are on page 1of 2

Assignment 1

Verifiable Procedural Program

IMPORTANT: This assignment must be done individually

Read Section 1 to understand the programming requirements, Section 1 to understand the programming
tasks that you need to carry out and Section 3 to know what you need to submit as the result.

1. Description
In this assignment, you will design and implement a verifiable procedural program named Series. This
is a simple program to provide user with utility methods to manipulate with a series of integers.
Your starting point is the pseudocode of the program as below:
1 Set series to an integer array returned by invoking method inputSeries()
2 Repeat
3 Invoke menu():int to display menu & get the user choice
4 If user choose min
5 Invoke method min(int[]):int – display the minimum element in the
series
6
If user choose max
7
Invoke method max(int[]):int - display the maximum element in the
8
series
9
If user choose sum
10
Invoke method sum(int[]):int - display the sum of elements in the
11 series
If user choose average
Invoke method average(int[]):double - display the average value of
the series
If user choose input series
Invoke method inputSeries() to input another series
If user choose quit
Quit the program
Until user quit the program

Listing 1: pseudocode of the Series program

2. Task requirements
1. Specify class Series that contains these operations:
 inputSeries(): int[] – ask user how many numbers they want to add (at least 1), then use a

PPL redo Page 1 of 2 Fall 2018


loop to get each number into the series, and finally returns the series.
 min(int[]):int – take an integer array as input, return minimum element in that array
 max(int[]):int – take an integer array as input, return maximum element in that array
 sum(int[]):int – take an integer array as input, return the sum of elements in that array
 average(int[]):double – take an integer array as input, return average value of that array
 menu(): int – display menu for user to choose with these options & return user’s choice as an
integer
o show mininum element in the series,
o show maximum element in the series,
o show sum of elements in the series
o show average value of the series,
o input another series,
o OR quit the program.
 main(): to run the program (see Listing 1)

2. Implement class Series in Java using the design specification that you wrote in task 1. Execute
the program with some test data to check that it works.
Note:
 You must not use class (static) variables

3. Submission requirements
You must submit a single zip file containing the class Series (top-level package) to the portal by the due
date. The zip file name must be of the form a1_Sid.zip, where Sid is your student identifier (the
remaining bits of the file name must not be changed!). For example, if your student id is 1601040123
then your zip file must be named a1_1601040123.zip.
IMPORTANT: failure to name the file as shown will result in no marks being given!
NO PLAGIARISM, in case of plagiarism - 0 mark will be given!

PPL redo Page 2 of 2 Fall 2018

You might also like