Workshop 1
Workshop 1
Duration: 60’
======================================================================
Software Requirements
Netbean 8.2 or later, JDK 8, Notepad, Command Prompt, WinRAR / WinZip with Windows
Explorer (File Explorer) on Windows 7 and above.
Students are ONLY Allowed to use:
His / her study materials like sample codes and program examples are stored on his / her
computer only.
Instructions
Step 1: Students download the given materials from the exam software.
Step 2: Students read questions and prepare answers in the given template.
Step 3: Prepare to submit the answer:
o For each question (e.g., question 1), please create two sub-folders: run and src.
o Copy the *.jar file into the run folder, and the entire project source code file into the
src folder.
Step 4: Submit a solution for each question:
o Choose the question number (e.g., 1) in PEA software, and then attach the
corresponding solution folder (e.g., 1). Click the Submit button to finish submitting
this question.
o
Note:
o Solutions will be marked by Automated Marking Software.
o The use of tools other than those allowed in the above section whether intentionally or
unintentionally, is considered a violation of the exam rules, and the exam result will be 0.
o Do not change the names of the folders and files specified (or required ) in the exam and the
name of the submit folders in Step 04 must be correct. If you change it (incorrectly), the
marking software can not find the execute file (.jar) to mark, thus the exam result will be 0.
======================================================================
Question 1: (5 marks)
Write a class JavaBasic (in the default package of the NetBean) with the following information:
1
JavaBasic Where:
calculate(a : int, b: int, op: char): void – print
the result is printed out to the monitor of the
operator a with b (Format real numbers with
+ calculate(a : int, b: int, op: char): void
2 decimal places)
+ indexOf(a: int[], int key): int
indexOf(a: int[], int key): int – return the
+ minOf(a: int[]): int index of key in array a, otherwise return -1
minOf(a: int[]): int - return the minimum
value in array a
Question 2: (5 marks)
Write a class MyString (in the default package of the NetBean) with the following information:
MyString Where:
reverseWords(s: String): String
– return the reverse words of
string s
+ reverseWords(s: String): String
capitalizeFullName((s: String):
+ capitalizeFullName((s: String): String
String – return the capitalize
of string.