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

HIGHER EDUCATION PROGRAMMES

Academic Year 2024: January - June

Formative Assessment 2: Systems Development 1 (HSYD100-1)

NQF Level, Credits: 5, 12

Weighting: 25%

Assessment Type: Essay Questions

Educator: Ronique Raats

Examiner: O.Dyantyi

Due Date: 10 May 2024

Total: 50 marks

Instructions:

• This paper consists of 3 questions.


• It is based on chapters 4 - 8 of your prescribed textbook.
• All questions are compulsory.
• Zip your Java NetBeans project folder and submit it as a zip folder AND a
single
• PDF document (clearly label your answers – show which question you are
answering).

NB All your answers must be both in a PDF (theory and source code)
and NetBeans project folder (source code for live testing).

1 HSYD100-1-Jan-Jun2024-FA2-OD-V.2-08112023
• A Copyleaks Report will be issued via ColCampus once the assignment is
submitted. Please ensure that you follow the correct steps when uploading your
assignment, to ensure that the Copyleaks Report is correctly issued. You
should be working towards a similarity rating of 30% or less. Where a Copyleaks
Cheat Detection Report is issued, your submission will automatically be treated
as if you received a similarity rating in excess of 30%. Currently, no marks will
be deducted for a similarity rating that exceeds 30%.

The assessment covers the following learning outcomes:

• Make decisions with the if and if…else statements.


• Create for or while loop.
• Use Character class methods.
• Use a variety of String methods.
• Declare an array.
• Initialize an array.
• Declare and use arrays of objects.
• Search an array.
• Sort array elements

Question 1 [11 marks]

1.1 Differentiate between the if statement and the if...else statement in Java. (2 marks)

1.2 Provide an example of an if statement (4 marks)


Write source code

1.3 Provide an example of if…else statement (5 marks)


Write source code

2 HSYD100-1-Jan-Jun2024-FA2-OD-V.2-08112023
Question 2 [10 marks]
2.1 You're working on a user registration system. Users are required to provide a
password that contains at least one special character. Write a Java program that
inputs a user's password and checks whether it contains at least one special character.
Use the Character class methods to determine if a character is a special character. If
the password is valid, display the message "Password accepted," otherwise, display
"Password must contain at least one special character."
(10 marks)
Paste/write source code

Criteria Task/Activity Allocated marks


Input Read password 2 marks
Processing Checking if the password
5 marks
has a special character
Password validity Check if the password is
valid (accepted or not 3 marks
accepted)

Question 3 [29 marks]


You are building a library management system. An object of the Book class represents
each book in the library. Declare an array of Book objects to store information about
five different books.

3.1 The following is a Book class and an incomplete program that declares an array
of Book objects to store information about five different books. Provide the missing
code that displays the book list. (4 marks)

1. public class Book {


2. private String title;
3. private String author;

3 HSYD100-1-Jan-Jun2024-FA2-OD-V.2-08112023
4. public String getTitle() {

5. return title;
6. }
7. public void setTitle(String title) {
8. this.title = title;
9. }
10. public String getAuthor() {
11. return author;

12. }
13. public void setAuthor(String author) {
14. this.author = author;
15. }
16. public Book(String title, String author) {
17. this.title = title;

18. this.author = author;


19. }
20. }

1. public class LibrarySystem {


2. public static void main(String[] args) {
3. Book[] books = new Book[5];
4. books[0] = new Book("Java Programming", "John Smith");
5. books[1] = new Book("Data Structures", "Alice Johnson");
6. books[2] = new Book("Machine Learning", "David Williams");
7. books[3] = new Book("Algorithms", "Emily Davis");
8. books[4] = new Book("Web Development", "Michael Brown");
9. MISSING statement? (2 marks)
10. MISSING statement? (2 marks)
11. MISSING statement?
12. }//end main method

4 HSYD100-1-Jan-Jun2024-FA2-OD-V.2-08112023
13. }//end class LibrarySystem

3.2 In your library management system, a user wants to search for a specific book by
its title. Implement a method searchBook that takes the array of Book objects and a
target title as parameters and returns the index of the book if found, or -1 if not found.
(9 marks)
1. public class LibrarySystem {
2. public static void main(String[] args) {

3. Book[] books = new Book[5];


4. books[0] = new Book("Java Programming", "John Smith");
5. books[1] = new Book("Data Structures", "Alice Johnson");
6. books[2] = new Book("Machine Learning", "David Williams");
7. books[3] = new Book("Algorithms", "Emily Davis");
8. books[4] = new Book("Web Development", "Michael Brown");
9. MISSING statement?
10. MISSING statement?
11. MISSING statement?
12. MISSING statement? (2 marks)
13. }//end main method
14. MISSING statement? (2 marks)
15. MISSING statement? (1 mark)
16. MISSING statement? (2 marks)
17. MISSING statement? (1 mark)
18. MISSING statement?
19. MISSING statement?
20. MISSING statement? (1 mark)
21. MISSING statement?

22. }//end class LibrarySystem

3.3 You want to display the list of books in your library management system
alphabetically by title. Implement the insertion sort algorithm to sort the array of Book
objects based on their titles. (16 marks)

5 HSYD100-1-Jan-Jun2024-FA2-OD-V.2-08112023
1. public class LibrarySystem {
2. public static void main(String[] args) {
3. Book[] books = new Book[5];
4. books[0] = new Book("Java Programming", "John Smith");
5. books[1] = new Book("Data Structures", "Alice Johnson");
6. books[2] = new Book("Machine Learning", "David Williams");
7. books[3] = new Book("Algorithms", "Emily Davis");
8. books[4] = new Book("Web Development", "Michael Brown");
9. MISSING statement? (1 mark)
10. MISSING statement?
11. MISSING statement?
12. MISSING statement?
13. }//end main method
14. MISSING statement? (2 marks)
15. MISSING statement? (2 marks)
16. MISSING statement? (1 mark)
17. MISSING statement? (2 marks)
18. MISSING statement? (2 marks)

19. MISSING statement?


20. MISSING statement? (2 marks)

21. MISSING statement? (2 marks)


22. MISSING statement?
23. MISSING statement? (2 marks)
24. MISSING statement?
25. MISSING statement?
26. }//end class LibrarySystem

6 HSYD100-1-Jan-Jun2024-FA2-OD-V.2-08112023

You might also like