Está en la página 1de 5

ISYS90088 Introduction to Application Development

Semester 2, 2018
School of Computing and Information Systems
The University of Melbourne

Assignment 1
Due date: Monday 27th August 2018, 11.30pm

This assignment is worth 20 marks, and will count as 10% of your final mark in this subject. The
assignment specification is on the ISYS90088 GROK environment, under the heading ‘Assignment 1’
(https://groklearning.com/learn/unimelb-isys90088-2018-s2/ass1/0/).
There are FOUR (4) questions in this assignment worth a total of 20 marks (accounting for 10% towards
your final mark). Answer all four questions. This is an individual project. While you may discuss the
problems with your classmates, you must not show written solutions to another student or use written
solutions from another student.
You are reminded that your submission for this project is to be your own individual work. For most people,
collaboration will form a natural part of the undertaking of this project. However, it is still an individual
task, and so reuse of code or excessive influence in algorithm choice and development will be considered
misconduct. We will check submissions for originality and will invoke the University’s Academic Mis-
conduct policy (http://academichonesty.unimelb.edu.au/policy.html) where inappropriate lev-
els of collusion or plagiarism appear to have taken place. Your code will be passed through our plagiarism
software.
Late submissions: A 10% penalty will be applied for each ‘late’ day and no late submissions will be
accepted after 5 days from deadline. If you submit after the deadline, your submission will be treated as
late and will be penalised.
Marking Rubric for this assignment: A sample marking rubric is uploaded on the LMS for your informa-
tion.
Note:
Three types of automated test cases will be run against your submission on GROK: (i) example test cases
from the examples given to you in the specification - you will see a tick mark if you pass them; (ii) hidden
test cases—you won’t see the test cases but you will receive a tick if your code has passed each of them; and
(iii) assessment test cases, which you will not see, but the markers will see and use to assess your project.
Read the specification carefully and follow the instructions for each question.
Only assessment test cases will be used to calculate your mark, as outlined in the marking rubric. Make
sure to use a good programming style that includes relevant comments and formatting of the code. Five (5)
marks out of the 20 will be allocated to style, formatting and approach to solving the questions.
Good Luck!

Dr Antonette Mendoza, semester 2 2018

1
Background
In this assignment we are using Python concepts taught in weeks 1–5 of the semester. This includes
• expressions, statements, programs, data types, operators and strings,
• built-in functions and methods, such as mathematical functions or string methods,
• control flow, such as making decisions, looping over a range, or advanced looping.
The assignment will be submitted via GROK and assessment will be carried out using GROK test cases.
The questions have been entered into GROK and initial test cases provided to get you started. You are
encouraged to generate your own test cases and test your code thoroughly to avoid surprises.
For each question, you are asked to write a short Python program. The program for each question will be
self-contained and will use the input() function to gather information from the user (or the test case), and
the print() statement to report its results.
Each question gives samples sessions with the program you are to write, giving the input and the required
output. Due to the GROK assessment process, your output is required to match the sample exactly, including
spacing. You should have practiced this procedure in the week 2–5 labs.
You are not expected to check the input for errors, and nor are you expected to print error messages or throw
exceptions. For Assignment 1, the test cases will not contain abnormal inputs. On the other hand, there is
no penalty for applying ordinary defensive programming practices.

Question 1 (3 marks): Subnormal Distribution


Marks for ISYS90088 have been released! There are n students in the course, and the teaching staff have
determined that the marks are normally distributed with a mean of µ and a standard deviation of σ . That is,
the number of students who got a mark of x can be estimated by

n (x−µ)2

f (x) = √ e 2σ 2 ,
2πσ 2
where x is taken to be an integer in the range 0..100 and f (x) is n times the probability density function
(PDF) of the normal distribution1 .
Write a program that accepts three float numbers n, µ and σ , followed by an int number t. Output an
estimate of the number of students who received a mark of t or less, as a float. Note that although x from
above and t mentioned here are related, they are not exactly the same thing!
First sample session with the program:
n? 270
mu? 80.5
sigma? 17.5
t? 50
Estimated number of students with 50 or less is 11.668020319410365
Second sample session with the program:
n? 220
mu? 68
sigma? 21.75
t? 80
Estimated number of students with 80 or less is 157.62056464986438
1 see https://en.wikipedia.org/wiki/Normal_distribution

2
Question 2 (5 marks): Would You Like A Receipt?
You are asked to create a receipt generation module for your company’s Point of Sale software.
The receipt will consist of heading lines, then one line per product sold, and then several summary lines
giving the total price, GST, and change calculation. The lines will be 40 characters long.
For each item sold, you will ask the user three questions: The name of the item, the quantity sold, and the
unit price. If the name of the item is empty (the user just presses Enter) it means there are no more items
and you will instead ask the user for the amount of cash paid, and then finish the receipt.
To simplify the scenario (because weeks 1–5 of the course do not cover storage of data in the computer’s
memory) we will ask for the information progressively, and print the information as it is received. Note that
the total and GST lines will be printed before asking for the amount of cash paid.
The formatting of the receipt must be as follows:
• The first heading line has to say ‘WELCOME TO MY STORE’ on the left, then spaces, then ‘TAX INVOICE’
on the right. The second heading line has to say ‘ABN 00 000 000 000’.
• There must be a blank line between the heading lines and the items.
• The item lines must have 25 columns for the item name, 5 columns for the quantity sold (an integer)
and 10 columns for the line price (the quantity times the unit price; with two decimal places). The
item name must be printed in uppercase.
• There must be a blank line between the items and the summary lines.
• The summary lines must be, in order: (i) ‘TOTAL’ in 30 columns followed by the total in 10 columns
(with two decimal places), and similarly for (ii) ‘GST INCLUDED IN TOTAL’, (iii) ‘CASH PAID’ and
(iv) ‘CHANGE’. The GST included in the total is calculated by dividing the total by 11.
Sample session with the program:
WELCOME TO MY STORE TAX INVOICE
ABN 00 000 000 000

Item name? baked beans


Quantity? 5
Unit price? .7
BAKED BEANS 5 3.50
Item name? corn flakes
Quantity? 1
Unit price? 4.75
CORN FLAKES 1 4.75
Item name? milk
Quantity? 2
Unit price? 2
MILK 2 4.00
Item name?

TOTAL 12.25
GST INCLUDED IN TOTAL 1.11
Cash paid? 20
CASH PAID 20.00
CHANGE 7.75
Ignoring the questions to the user in the above, would reveal a neatly formatted receipt:

3
WELCOME TO MY STORE TAX INVOICE
ABN 00 000 000 000

BAKED BEANS 5 3.50


CORN FLAKES 1 4.75
MILK 2 4.00

TOTAL 12.25
GST INCLUDED IN TOTAL 1.11
CASH PAID 20.00
CHANGE 7.75

Question 3 (6 marks): Spy Versus Spy


You are engaged in some important negotiations with a client in a foreign country. Each night during the
negotiations, you communicate with head office from your hotel room about the progress of the deal.
Due to the likelihood of industrial espionage, your communications will be in code. You have previously
arranged with head office that the code will be based on a particular chapter from the novel (fiction book)
that you carry innocently in your luggage.
Write a program which accepts two strings: Firstly, the message to be encoded, and secondly, a sufficient
amount of keytext (taken from the novel and agreed with head office). The message and keytext will be in
telegram style, strictly in uppercase with no punctuation or spaces. Encode the message as follows:
• Each character of the keytext should be converted to a number in the range 0..25, such that ‘A’ is 0,
‘B’ is 1 and so on.
• Each keytext number should be added to the corresponding letter of the message to produce the
encoded message, such that ‘A’ + 0 is ‘A’, ‘A’ + 1 is ‘B’, and so on.
• The addition wraps around after ‘Z’, such that ‘Y’ + 1 is ‘Z’, ‘Y’ + 2 is ‘A’, and so on.
For each character of the message, print a line of output giving the character to be encoded, the keytext
number (0..25), and then the resulting encoded character, separated by spaces.
First sample session with the program:
Message? HELLO
Keytext? AAAAA
H 0 H
E 0 E
L 0 L
L 0 L
O 0 O
Second sample session with the program:
Message? HELLO
Keytext? BBBBB
H 1 I
E 1 F
L 1 M
L 1 M
O 1 P
Third sample session with the program:
Message? BIGPROBLEMS
Keytext? HELLOSAIDJOHN

4
B 7 I
I 4 M
G 11 R
P 11 A
R 14 F
O 18 G
B 0 B
L 8 T
E 3 H
M 9 V
S 14 G
Hint: To create a complex program such as this one, you will need to apply a process of development in
which you add each feature gradually. A suggested strategy would be as follows:
• Start with a program that just prints the message one character per line (the first column of output).
Run this to make sure that it works correctly.
• Then, make your program do the same thing, but by taking the ASCII code of the character and then
converting the ASCII code back to a character.
• Then, make it also calculate and print the keytext number (the second column of output), make sure
this also works correctly, and so on.

Question 4 (6 marks): Deja Vu


Your company is creating the next WinZip! WinZip is a popular program that makes your files smaller to
save storage space and download times. You are a new hire on the data compression team, and you are
asked to create the first processing stage, in which repeated data is identified for further checking.
Your task is to obtain from the user a text string to be compressed, and then replace each repeated character
in this text string with a relative index to the previous occurrence of the character, thus creating a list that is
linked (so that recent substrings beginning with a given character can be located easily).
You must output each repeated character as an open parenthesis, a negative number, and then a close paren-
thesis. This counts as only one position in the resulting string. You may assume that there are no parentheses
in the input, or that if there are, they need not be distinguishable from any parentheses you add.
For example, given the text string ‘hello’, you will output the string ‘hel(-1)o’, indicating that after
‘hel’ there is a repeated character which can be found by going backwards one character in the string.
Multiple repeats point to the most recent, for instance ‘aardvark’ gives ‘a(-1)rdv(-4)(-4)k’.
First sample session with the program:
Text to compress? hello
hel(-1)o
Second sample session with the program:
Text to compress? aardvark
a(-1)rdv(-4)(-4)k
Third sample session with the program:
Text to compress? The cat in the hat
The cat(-4)in(-3)(-5)(-11)(-11)(-4)(-3)(-11)(-6)

End of assignment.

También podría gustarte