Java Programming Assignment on eclipse

umairchill5
Assignment1.pdf

Assessment item 1 - Assessment 1: Programming

Tasks

back to top

Value: 20% Due Date: 21-Aug-2020 Return Date: 11-Sep-2020 Submission method options: Alternative submission method

TASK

back to top

Task 1: Exception Handling (5 marks)

Write a method that accepts two integer prime numbers and returns their product. If either

argument is not prime, throw a custom PrimeNumberException and report the number(s) that

are not prime. Your custom exception should be a checked exception. In addition to the

above, write some code to show how your method works when called with the following

arguments:

• Two prime numbers

• One prime and one non-prime number

• Two non-prime numbers

Task 2: File Processing (5 marks)

Write a program that takes a text file name as a runtime argument. If the text file does not

exist, print an error message and terminate the program. Otherwise, have your program

calculate the number of characters in the file (ignore any white space) and print the result.

Task 3: Rectangles (5 marks)

Write a program that allows a user to create and display rectangle objects. You should write

your own Rectangle class for this purpose. Your program should have the following main

menu:

## Rectangle Program ##

1. Enter rectangle details

2. Show all rectangles

3. Exit program

If option 1 is selected: Ask the user for a length in centimetres (a float) and a width in

centimetres (a float) to create a new rectangle. If the rectangle is successfully created, add it

to an ArrayList and report a success message back to the user before re-showing the menu

above. If there was an error creating the rectangle (because the user entered non-numeric data

or a negative value for the length or width), or if there was an error adding the rectangle to

the list, report an appropriate message before re-showing the menu above.

If option 2 is selected: Print out the length, width and area of each rectangle to two decimal

places, ordered by area, so that details of the smallest rectangle will be printed first and

details of the largest rectangle will be printed last (see example output below). Have your

Rectangle class implement the Comparable interface to assist with this task.

Example output for this option:

Length: 2.14cm, Width: 3.57cm, Area: 7.64cm

Length: 3.99cm, Width: 5.11cm, Area: 20.39cm

Length: 5.0cm, Width: 13.4cm, Area: 67.00cm

If option 3 is selected: Terminate the program

Task 4: JavaFX Archery Target (5 marks)

Write a GUI program that displays an archery target within a small window, as per the image

below. For the window background use dark sea green; for the archery circles, use white,

black, cyan, red and gold. Make sure that your target is centred in the middle of the window,

and that the circles are evenly spaced. Design your window so that the user is not able to

resize it.

Task Marks PS CR DI HD

1 5

Minor output

problems, or

correct output

but task

requirements not

completely

fulfilled.

Problems with

Java coding

implementation.

Correct output

but minor errors

with prime

number method

implementation

and/or exception

handling

techniques.

Minor problems

with Java coding

implementation.

Correct output. All required

programming elements present

but minor problems with

efficient implementation or Java

coding standards.

Correct output.

Efficient

implementation of

prime number

detection method.

Appropriate exception

handling techniques.

Java coding standards

followed.

2 5

Minor output

problems, or

correct output

but task

requirements not

completely

fulfilled. Issues

with Java coding

implementation

and/or exception

handling

Correct output

but with minor

issues around

exception

handling

techniques.

Minor problems

with efficiency of

Java

implementation

or coding

standards.

Correct output. Robust program

with appropriate exception

handling techniques. Minor

problems with efficiency of

Java implementation or coding

standards.

Correct output.

Robust program with

appropriate exception

handling techniques.

Java coding standards

followed.

3 5

Minor output

problems, or

correct output

but task

requirements not

completely

fulfilled. Several

Issues with Java

coding

implementation

and/or exception

handling and/or

user interface.

Correct output.

Robust program

with appropriate

exception

handling

techniques.

Several minor

problems with

efficiency of Java

implementation,

coding standards

and user

interface.

Correct output. Robust program

with appropriate exception

handling techniques. Minor

problems with efficiency of

Java implementation or coding

standards or user interface.

Correct output.

Intuitive user

interface. Robust

program with

appropriate exception

handling techniques.

Java coding standards

followed.

MARKING CRITERIA AND STANDARDS

RATIONALE

This assessment task will assess the following learning outcome/s:

• be able to create, manage and manipulate objects via the Java Collections

Framework.

• be able to design and construct Java Graphical User Interfaces (GUI) that interact

with problem domain objects.

• be able to demonstrate the use of the inheritance features of the Java language to

design and implement complex object-oriented programs.

REQUIREMENTS

back to top

Each task should be completed as a new Java project within your IDE. Compress each of the

four projects (one for each task) into a single zip or rar file for submission to Turnitin.

4 5

Minor output

problems.

Several issues

with code

implementation.

Correct output.

Several issues

with code

implementation.

Correct output. Minor issues

with code implementation.

Correct output. Java

coding standards

followed.