Requirement
INFO1103 Introduction to Programming, Semester 2, 2016
1
Task 2 Latin Squares
Submission deadline: 5pm on Saturday, 3 rd September (Week 6)
Submission: Submit your LatinSquares.java file via the online system PASTA.
Weight: 5 marks = 5% of your final mark.
This assessment must be completed individually.
Write a program called LatinSquares.java that checks if an n x n matrix is a Latin square. Your
program should be in the package squares and should be based off the skeleton code available on
PASTA.
A n x n matrix is a Latin square if every row and column contains the numbers 1, 2, 3,… n, exactly once. For
example:
A Latin square of size 3:
3 2 1
1 3 2
2 1 3
A Latin square of size 5:
1 2 3 4 5
2 3 5 1 4
3 5 4 2 1
4 1 2 5 3
5 4 1 3 2
The name “Latin square” was inspired by the work of the Swiss mathematician Leonhard Euler, who used
Latin characters as symbols. Other symbols can be used instead of Latin characters, e.g. integer numbers, as
in this assignment. Latin squares are used for experimental design in statistics, for error correcting codes in
telecommunication systems and are also related to the Sudoku puzzles. See the Wikipedia page on Latin
Squares for more information ().
Download the LatinSquares.java skeleton code from PASTA. This skeleton code contains a template
for your submission. You must not modify the existing method headers as we use them to test your code,
however you may add any additional methods you believe are necessary.
Your task is to write the methods readSize, readSquare, validColumn, validRow, and
validLatinSquare as described in the skeleton code. Your complete program will include the given
skeleton code and the methods that you will write.
Your code will be tested at the method level, which means each method will be tested individually, not just
by running the main method. This means you need to make sure that each method works exactly as the
documentation in the skeleton code describes.
See below for some example outputs of the main method being run. The text in black is required output, and
the text in green is user input.
INFO1103 Introduction to Programming, Semester 2, 2016
2
Please enter the size of the square (N):
3
Please enter 9 numbers:
1 2 3 2 3 1 3 1 2
This is the square you input:
+‐+‐+‐+
|1|2|3|
+‐+‐+‐+
|2|3|1|
+‐+‐+‐+
|3|1|2|
+‐+‐+‐+
It’s a Latin square!
Please enter the size of the square (N):
3
Please enter 9 numbers:
0 2 1 1 0 2 2 1 0
This is the square you input:
+‐+‐+‐+
|0|2|1|
+‐+‐+‐+
|1|0|2|
+‐+‐+‐+
|2|1|0|
+‐+‐+‐+
Not a Latin square!
Please enter the size of the square (N):
2
Please enter 4 numbers:
1 2 3 4
This is the square you input:
+‐+‐+
|1|2|
+‐+‐+
|3|4|
+‐+‐+
Not a Latin square!
Please enter the size of the square (N):
3
Please enter 9 numbers:
1 2 3 1 2 3 1 2 3
This is the square you input:
+‐+‐+‐+
|1|2|3|
+‐+‐+‐+
|1|2|3|
+‐+‐+‐+
|1|2|3|
+‐+‐+‐+
Not a Latin square!
Assumptions
You can make the following assumptions for this task:
Your code will only be given sensible input (e.g. ? ? 0).
Any inputs will be given as integers only; you do not need to worry about invalid inputs like floating
point numbers or Strings.
How to Submit in PASTA
Writing your code
1. In Eclipse, create a project “info1103_task2”. In this project, create a package “squares”, and then a
class “LatinSquares” within the package.
2. Download the skeleton code from PASTA and either import the class or paste the code into the class
“LatinSquares.java”.
3. Write the required methods. You may not change any method headers in the skeleton code! Your
program consists of the provided skeleton code and the methods that you wrote. Compile and run
your program and make sure that it produces the same output as the example output. When you are
happy with your program, you need to submit it on PASTA.
INFO1103 Introduction to Programming, Semester 2, 2016
3
Submitting in PASTA
1. Log in to PASTA () with your Unikey login and password.
Note: If you are off-campus, you will need to establish a VPN connection to access PASTA. This means
installing a program called “VPN client” on your computer and running it every time when you use PASTA
off-campus. Instructions how to do this are available here:
access-the-university-network%3F
If you have problems with VPN, try synchronising your password:
If this doesn’t work, contact the ICT helpdesk:
2. Find Task 2 and press “Submit”. Then press “Choose File” and attach the LatinSquares.java
file, then press “I accept” (after reading the University policy on academic honesty).
3. If you see a message indicating that your code is queued for testing under Task 2, this means that
your code has been uploaded successfully.
4. If you see a red error box, you need to fix any problems indicated before your submission will be
accepted.
5. Once your program has been tested, the page will tell you to refresh for results, so refresh the page.
You should see green, red and grey boxes. Each box corresponds to a test; a red box indicates that
your program has failed the respective test, a green box indicates that your program has passed the
test, and a grey box indicates that the test is hidden (you will not see the result of the test until after
the due date).
6. If you have red boxes, you can see which tests were not passed by clicking on the task name. Correct
the errors (go to Eclipse, re-write your code and test it carefully) and then submit again in PASTA.
7. For further help on using PASTA, check the INFO1103 User Manual, or post a question on Piazza.
Marking
Your mark is the percentage of the tests that you have passed, e.g. for Task 2: all 20 tests passed, the
mark is 100% of 5 marks = 5 marks, 10 tests passed, the mark is 50% of 5 marks = 2.5 marks.
You can submit as many times as you want. Please make sure that your program compiles and runs
before you submit it in PASTA. Your last submission will be the one that will be marked.