辅导 KXO151、讲解 Java编程设计
            
                Page 1 of 10
KXO151 Programming &	Problem	Solving
AIEN-SHOU	- 2025
Assignment	2
Deadline	for	Submission: 9PM	(Shanghai)	Wednesday,	Week	8,	16 April 2025
Maximum	Marks	Available:	 15	(15%	of	the	total	assessment	for	KXO151)
Submission: Via	MyLO
NOTE: All	assignments	will	be	checked	for	plagiarism	by	a	specialist	Java	program	that	checks	
your	assignment	against	other	student’s	assignments	as	well	as	the	Internet	(including	help	
sites).
Assignment	Type: Individual
Requirements:
PLEASE	NOTE: This	assignment	is	to	be	completed	by	Students	individually.	If	you	need	help,	please	
look	 at	 the	 textbook or	 ask	 your	 lecturer.	 Students	 who	 have	 been	 working	 through	 the	 tutorial	
exercises	should	not	have	much difficulty in	completing	this	assignment.
PLEASE	NOTE: The	submitted	Java	code	must	be	able	to	be	compiled	from	the	command	line	using	
Javac	the Java	programming	language	compiler command,	or	from	a	basic	editor	such	as	jGrasp.	Be	
aware	that	development	programs	such	as	Eclipse	often	use	features	only	available	when	run	using	
their	system,	meaning	that	their	code	may	not	run	on	a	system	without	their development	program.	
Programs	that	do	not	run	from	the	command	line	using	javac	(to	compile)	and	java	(to	run)	because	
of	a	missing	development	program	feature	will	fail	the	assignment.		
You	are	required	to	perform	the	following	tasks:
Write	 a	 Java	 application	 program	 named	 Asst2.java which	 provides	 the	 user	 with	 their	
'personalised '	 number.	 The	 details (specifications)	 of	 this	 task	 are	 given	 below.	 Note	 that	 the	
correctness	 marks	 you	 receive	 for	 your	 program	 will	 depend	 on	 how	 well	 it matches	 this	
specification.	If	you	decide	to	implement	something	that	is	more	elaborate	than	specified,	you	should	
understand	that:
• There	will	be	no	marks	awarded	for	the	elaborations	you	have	designed	and	penalties	may	
be	applied	for	confusing/extraneous	code.
• Your	program	must	still	meet	the	basic	specifications	given	below.
The	program	is	to	implement	a	simple	personalised number	program.	The	user	will	be	asked	four	
questions	about	themselves.
• Their	family	name	(to	be	stored	in	a	String	that	may	not	contain	spaces).
• The	initial	(first	letter) of	their	first	given	name	(to	be	stored	in	a	char).
• Their	year	of	birth	(to	be	stored	in	an	int	variable).
• Whether	or	not	they	are	female	(to	be	stored	in	a	boolean	variable).
The	answers	to	these	questions	will	be	used	to	generate	a	' personalised '	number	(in	the	range	of	1	
to	9)	 for	 the	user,	 this	will	be	displayed	on the	screen. To	calculate	 the	' personalised '	number,	
several	values	will	be	used:
• An	initial	' personalised '	number	value	of	 5.
• A	family	name	factor	length	of	5.
• Special	letters	‘A’,	'S', ‘T’	and'Z'.
The	user	will	always	see	one	' personalised '	number.
NOTE:	Part	of	the	assessment	of	your	program	may	be	done	automatically,	so	it	is	important	that	you	
follow	the	specification	exactly,	for example	the	questions	must	be	asked	in	the	order	given	and	the	
method	the	user	is	given	to	indicate	that	they	want	to	see	another fortune	must	be	as	specified.
Details
• The	 user	 will	 be	 asked	 to	 enter	 their	 family	 name. (Rules:	 The entry	 should	 not	 contain	
spaces.)
• The	user	will	be	asked	to	enter	the	first	letter	of	their	first	name.
• The	user	will	be	asked	to	enter	the	year	of	their	birth.
• The	user	will	be	asked	to	enter	true/false	as	to	whether	they	are	female.
• All	the	above	information	should	then	be	displayed	to	the	user	in	the	form	(with	sample	data	
of	"Clark",	"J",	1989,	true)	of:
J.Clark (male) was born in 1989.
• The	program	will	then	work	out	the	user's	'personalised '	number	as	follows:
o Starting	with	5 as	an	initial	number,	if	the	birth year is	even	then	the	number	will	be	
9	times (number=	initial	number*9).
if	the	birth	year	is	odd	then	the	number	will	be	multiple	of	3 times (number=	initial	
number*3).	
o If	the	user	is	female, then:
§ if	the	initial	of	their	first	name	is	either	of	the	special	letters [A,	S,	T	or	Z]
then	the	number	is	5 times (number=	initial	number*5);	otherwise, it	is	2
times	(number=	initial	number*2).
o otherwise,	for	a	male	user
§ if	the	length	of	the	family	name	is	a	multiple	of	3	then	the	number	is	6 times	
(number=	initial	number*6);	otherwise, it	is	4 times	(number=	initial	
number*4).
o Finally,	the	number	is	reduced	and	calculated	by	summing	the	digits	of	the	
calculated	number until	a	single-digit	number	is	obtained.	If	the	result	is 0,	it	is	set	
to 1 to	ensure	the	personalised number	remains	between 1	and	9.
• The	Personalised number	is	then	displayed	on	the	screen.
• After	the	Personalised number	has	been	displayed,	the	user	is	asked	whether	they	want	to	
see	another.	To	see	another	personalised number, they	must	enter	the	character	'y'	or	'Y'	(for	
yes).	They	will	then	be	asked	for	another	family	name,	initial,	year,	and	gender	and	will	see	
another	personalised number.	If	they	enter	any	letter	other	than	'y'	or	'Y'	the	program	will	
stop.
• The	user	will	be	shown	a	message	saying	how	many	personalised numbers	were	told.
A	sample	output	of	the	program	is	attached	to	the	end	of	this	document.
Program	Style
The	program	you	write	for	this	assignment	must	be	a	single	class	called	Asst2 with	the	code	in	a	file	
called	Asst2.java. There	should	be	a	single	method	(the	main()	method)	in	this	class.
Page 2 of 10
Your	 program	 should	 follow	 the	 coding	 conventions	 introduced	 in	 this	 unit and	 shown	 in	 the	
textbook,	especially:
• Variable	identifiers	should	start	with	a	lower-case letter
• Final	variable	identifiers	should	be	written	all	in	upper	case	and	should	be	declared	before	
all	other	variables
• Every	if-else	statement	should	have	a	block	of	code	for	both	the	if	part	and	the	else	part	(if	
used)
• Every	loop	should	have	a	block	of	code (if	used)
• The	program	should	use	final	variables	as	much	as	possible
• The	keyword	continue should	not	be	used
• The	keyword	break should	only	be	used	as	part	of	a	switch	statement (if	required)
• Opening	and	closing	braces	of	a	block	should	be	aligned
• All	code	within	a	block	should	be	aligned	and	indented	1	tab	stop	(approximately	4	spaces)	
from	the	braces	marking	this	block
Commenting:
• There	should	be	a	block	of	header	comment	which	includes	at	least
o file	name
o your	name (in	pinyin)
o student	UTas	id	number
o a	statement	of the	purpose	of	the	program
• Each	variable	declaration	should	be	commented.
• There	should	be	a	comment	identifying groups	of	statements	that	do	various	parts	of	the	
task.
• There	should	not be	a	comment	stating	what	every	(or	nearly	every)	line	of	the	code	does	-
as	in:	
num1 = num1 + 1; // add 1 to num1
Save	the	Output	
Run	your	program	entering	data	via	the	keyboard	and	save	the	output	of	your	program	to	a	text	file	
using	your	UTas student	id	number	as	the	name	of	the	file,	for example,	159900.txt (in	jGrasp,	right	
mouse-click	in	the	‘Run	I/O’	window	and	select	‘Save	As	Text	File’).
Important	Notes:	
• Changing	a	few	variable	names,	adding	different	data	and	/	or	adding	your	name	to	the	top	
of	someone	else’s	code	does	not	make	it	your	own	work.	See	the	section	on	‘Plagiarism’	below.
• You	need	to	submit	2 files:	
o your		Asst2.java
o a	text	file	containing	the	output	of	your	program	using	your	UTas	id number	as	the	
name	of	the	file,	for	example,	159900.txt.	
o See	the	section	on	‘Submission’	below for	more	information.
• Before	you	submit	your	assignment	through	the	KXO151 MyLO	website,	it	is	suggested	that	
you	make	sure	the	final	version	of	your	Java	program	file	compiles	and	runs	as	expected	– do	
not	change	the	names of	the	java	 file – submit	it exactly	as	you	last	compiled	and	ran	it.
Programs	that	do	not	compile	and	/	or	run	will	fail	the	assignment.	If	in	doubt,	you	can	
Page 3 of 10
Page 4 of 10
click	on	the	submitted	files,	download	them	from	MyLO,	and	check	that	they	are	the	files	you	
think	they	should	be.	
NOTE: The	higher	marks	are	reserved	for	solutions	that	are	highly	distinguished	from	the	rest	and	
show	an	understanding	and	ability	to	program	using	Java	that	is	well	above	the	average.
Page 5 of 10
Guide	to	Assessment	and	Expectations:
The	assessment	of	Assignment	2	is	based	on	the	following	criteria:
Criteria High	Distinction Distinction Credit Pass Fail
Programming	
Requirement
Excellent	
programming	 ability	
to	 correctly	 prompt	
the	 user	 for	 inputs	
and	 store	 them	
appropriately. The	
program	 employs	 a	
loop	 structure	 to	
repeatedly	 prompt	
the	 user	 until	 they	
choose	 to	 exit. The	
program	 accurately	
assesses	 and	 provide	
the	information	as	per	
the	 requirements. It	
accurately	 calculates	
and	displays	 the	 total	
number	of	 times	user	
asks	 to	 run	 the	
program during	 the	
session.
Reasonable	
programming	 ability	
to	 correctly	 prompt	
the	 user	 for	 inputs	
and	 store	 them	
appropriately. The	
program	 employs	 a	
loop	 structure	 to	
repeatedly	 prompt	
the	 user	 until	 they	
choose	 to	 exit. The	
program	 reasonably
assesses	 and	 provide	
the	information	as	per	
the	 requirements. It	
accurately	 calculates	
and	displays	 the	 total	
number	of	 times	user	
asks	 to	 run	 the	
program during	 the	
session.
Good	 programming	
ability	 to	 correctly	
prompt	 the	 user	 for	
inputs	and	store	them	
appropriately. The	
program	 employs	 a	
loop	 structure	 to	
repeatedly	 prompt	
the	 user	 until	 they	
choose	 to	 exit. The	
program assesses	and	
provide	 the	
information	as	per	the	
requirements. It
calculates	 and	
displays	 the	 total	
number	of	 times	user	
asks	 to	 run	 the	
program during	 the	
session.
Some	 user	inputs	 are	
prompted	 or	 stored	
incorrectly. Loop	
structure	 is	 partially	
implemented	 or	
contains	minor	issues.
The	 program	
accurately	 assesses	
some	 of	 the	
requirements	 and	
provide	 the	
information	as	per	the	
requirements. It	
partially calculates	
and	displays	 the	 total	
number	of	 times	user	
asks	 to	 run	 the	
program during	 the	
session.
User	 inputs	 are	 not	
prompted	 or	 stored	
correctly. Loop	
structure	 is	 not	
implemented	 or	 does	
not	function	properly.
The information	
assessment	 is	
incorrect	 or	
incomplete. Total	
number	 of	 program	
runs	is	not	calculated	
or	displayed.
General	
Requirement
Excellent	 evaluation	
of	 the	 program's	
organization	 and	
visual	 presentation.
Assessment	 of	
adherence	 to	 coding	
standards	 such	 as	
naming	 conventions,	
use	 of	 constants,	 and	
in-line	 comments.
Check	 if	 the	 program	
includes	 the	
necessary	
information	 in	 its	
header.
Reasonable	
evaluation	 of	 the	
program's	
organization	 and	
visual	 presentation.
Assessment	 of	
adherence	 to	 coding	
standards	 such	 as	
naming	 conventions,	
use	 of	 constants,	 and	
in-line	 comments.
Check	 if	 the	 program	
includes	 the	
necessary	
information	 in	 its	
header.
Good	 evaluation	 of	
the	 program's	
organization	 and	
visual	 presentation.
Assessment	 of	
adherence	 to	 coding	
standards	 such	 as	
naming	 conventions,	
use	 of	 constants,	 and	
in-line	 comments.
Check	 if	 the	 program	
includes	 the	
necessary	
information	 in	 its	
header.
Some	 evaluation	 of	
the	 program's	
organization	 and	
visual	 presentation.
Assessment	 of	
adherence	 to	 coding	
standards	 such	 as	
naming	 conventions,	
use	 of	 constants,	 and	
in-line	 comments.
Check	 if	 the	 program	
includes	 the	
necessary	
information	 in	 its	
header.
No	 evaluation	 of	 the	
program's	
organization	 and	
visual	 presentation.
Assessment	 of	
adherence	 to	 coding	
standards	 such	 as	
naming	 conventions,	
use	 of	 constants,	 and	
in-line	 comments.
Check	 if	 the	 program	
includes	 the	
necessary	
information	 in	 its	
header.
Note The	High	Distinction	grade	is	reserved	 for	solutions	 that	 fully	meet	 the	requirements	&	are	highly	distinguished	 from	
other	assignments	by	their	high-quality	work	&	their	attention	to	detail	(usually	only	10%	of	students).
PLEASE	NOTE: The	assignment	will	receive	a	single	composite	mark.	The	assignment	will	be	accessed	
from	the	point	of	view	of	the	requirements:	“Does	it	meet	the	requirements,	and	how	well	does	it	do	
it?”	 	Where	 there	 is	 some	 inconsistency	 in	 that	 the	 work	 does	 not	 completely	 match	 every	 sub criterion within	a	particular	criterion,	then	the	grade	reflects	the	value	of	the	work	‘on	average’.	
Submission:
Your	 completed	 solution (your	 Asst2.java file,	 plus	 a	 text	 file containing	 the	 output	 of	 your	
program	 using	 your	 UTas	 id	 number	 as	 the	 name	 of	 the	 file,	 for	 example,	 159900.txt)	 must	 be	
submitted	by	the	deadline.	Assignments	must	be	submitted	electronically	via	KXO151 MyLO	website
as	files	that	can	be	read	by	a	text	editor	such	as	Microsoft	Notepad	(submit	the	*.java	file	- not	the	
*.class	file).	Follow	the	following	steps	to	create	a	package	for	your	assignment	files	and	then	submit	
your	package	file:
1.		On	your	computer	desktop,	create	a	new	folder	using	your	name	and	UTAS	ID	number.	
For	example,	if	you	name	is	Jianwen	Chen	and	your	UTAS	ID	number	is	159900,	then	the	
new	folder	must	be	named	Jianwen_Chen_159900;
2.	Copy	your	2	assignment	files	into	the	new	folder;
Page 6 of 10
3.	Use	the	WinRAR	application	to	compress	the	new	folder	and	name	it	as	*.rar.	For	
example,	Jianwen	Chen	would	name	it	as	Jianwen_Chen_159900.rar.
4.	Submit	your	*.rar	file	to	the	unit	MyLO	“Assessments/Assignments/Assignment	2”	folder.
5.	If	WinRAR	application	is	not	available	on	your	computer,	try	to	use	a	similar	application	
to	compress	the	new	folder	and	name	it	as	*.zip,	and	then	submit	the	*.zip	file.
Details	of	the	actual	submission	procedure	are	available	through	the	MyLO	webpages.	
Students	 who	 believe	 that	 this	 method	 of	 submission	 is	 unsuitable	 given	 their	 personal	
circumstances	must	make	alternative	arrangements	with	their	Lecturer	prior	to	the	submission	date.	
Extensions	will	 only	 be	 granted	 under	 exceptional	conditions	 and must	 be	 requested	with	
adequate	notice	on	the	Request	for	Extension	forms. No	extension	will	be	provided	after	due	
date.
In	submitting	your	assignment, you	are	agreeing	that	you	have	read	the	‘Plagiarism’	section	below,	
and	that	your	assignment	submission	complies	with	the	assignment	requirement	that	it	is	your	own	
work.
Plagiarism
While	students	are	encouraged	to	discuss	the	assignments	in	this	unit	and	to	engage	in	active	learning	
from	each	other,	it	is	important	 that	 they	are	also	aware	of	 the	University’s	policy	on	plagiarism.	
Plagiarism	 is	 taking	 and	 using	 someone	 else's	 thoughts,	 writings	 or	 inventions	 and	 representing	
them	as	your	own;	for	example, downloading	an	essay	wholly	or	in	part	from	the	internet,	copying	
another	student’s	work	or	using	an	author’s	words	or	ideas	without	citing	the	source.
Plagiarism	is	a	form	of	cheating.	It	is	taking	and	using	someone	else's	thoughts,	
writings	or	inventions	and	representing	them	as	your	own;	for	example,	using	an	
author's	words	without	putting	them	in	quotation	marks	and	citing	the	source,	using	
an	author's	ideas	without	proper	acknowledgment	and	citation	or	copying	another	
student’s	work.	
If	you	have	any	doubts	about	how	to	refer	to	the work of others in your assignments,
please	consult	your	lecturer	or tutor	for	relevant	referencing	guidelines,	and	the	
academic	integrity	resources on the web at:	www.academicintegrity.utas.edu.au/.
The intentional copying of someone else’s work as one’s own is a serious offence
punishable	by	penalties that	may	range	from	a	fine	or	deduction/cancellation of	marks
and, in the most	serious of cases, to exclusion from a unit, a course	or the	University.	
Details	of	penalties	that	can be imposed are available in the Ordinance of Student
Discipline – Part 3 Academic	Misconduct,	see:	
www.utas.edu.au/universitycouncil/legislation/
The University reserves the right to	submit assignments to plagiarism	detection	
software,	and	might	then retain	a	copy	of	the	assignment	on	its	database	for	the	
purpose	of future plagiarism checking.
It	is	important	 that	you	understand	 this	statement	on	plagiarism.	Should	you	require	clarification	
please	see	your	unit	coordinator	or	lecturer.		Useful	resources	on	academic	integrity,	including	what	
it	is	and	how	to	maintain	it,	are	also	available	at:	www.academicintegrity.utas.edu.au/.
Working	with	others,	including	generative	Generative	AI	tools (e.g.,	ChatGPT,	Codex,	Copilot)
One	effective	way	to	grasp	principles	and	concepts	is	to	discuss	the	issues	with	your	peers	or	friends	
(or	even	to	interact	with	one	of	the	many	generative	AI	tools	available	now),	and	you	are	encouraged	
to	do	this.	We	also	encourage	you	to	discuss	aspects of	practical	assignments	with	others.	However,	
once	you	have	clarified	the	principles of	the	question,	you	must	express	the	expression,	algorithm	or	
program	entirely	by	yourself.	In	other	words,	you	can	discuss	the	question,	but	not	the	solution.	Same	
applies	to	advanced	Generative	AI	tools,	we	do	not	encourage	students	solve	the	assignment	using	
advance	 AI	 tools,	 however,	 if	 you	 would	 like	 to	 take	 assistance	 from	 these	 AI	 tools	 to	 help	 to	
understand	the	question,	then	you	need	to	provide	below	detail:
If	you	get	help	from	an	AI	tool	with	a	programming	task,	add	this	at	the	top	of	your	source	file	
or	embed	the	contents	(excluding	the	top	and	bottom """)	into	the	program-level """	documentation	
comment	""" at	the	top:
"""
Acknowledgement of external assistance
Issues I got help with: WRITE 1-3 SHORT SENTENCES
Assistance received: WRITE 1-3 SHORT SENTENCES
Page 7 of 10
Page 8 of 10
What I learned: WRITE 1-3 SHORT SENTENCES
"""
After	the	appropriate	prompt	write	a	brief	summary	of:
• what	the	problem(s)	were	that	you	needed	help	with;
• what	assistance	the	external	tool	provided	(for	example,	did	it	identify	a	problem	in	syntax,	
or	an	issue	with	the	approach	you	were	using?)
• what	you	have	learned	from	its	suggestion(s)	(which	will	allow	you	to	solve	such	problems	
yourself	in	future)
If	 you	 get	help	 from	 an	AI	 tool	with	 a	 task	where	 you	produce	 a	 document,	either	 upload	a	
separate	Word	or	PDF	containing	the	same	details	as	above	or,	within	the	body	of	the	document,	add	
the	following	with	responses	after	each	of	the	three	prompts:
Acknowledgement	of	external	assistance
Issues	I	got	help	with: WRITE	1-3	SHORT	SENTENCES
Assistance	received: WRITE	1-3	SHORT	SENTENCES
What	I	learned: WRITE	1-3	SHORT	SENTENCES
Acknowledgement
This	assignment	has	been	adapted	from	a	programming	project	developed	by	Dr	Julian	Dermoudy.	The assignment	template	
was	written	by	Dr	Dean	Steer.
Page 9 of 10
Sample	Output	of	Assignment	2,	2025
C:\KXO151>java Asst2
Welcome to personalised number generator. 
This program will tell you your personalised number using your 
personal information!
Please enter your family name: Chen
Please enter your first initial: Z
Please enter the year in which you were born: 2002
True or false – you are female: false
Z.Chen (male) was born in 2002.
And has a personalised number of 2
Another? n
Thank you for using Personalised number generator, you have generated 
1 personalised number(s).
C:\KXO151>
Page 10 of 10
KXO151 Assignment Two Marking Scheme (2025)
Programming Requirements (for each item there are only 3 possible marks: 100% or 50% or 0%)
Requirement Item Mark 
Out of
PR1. Correctly obtain inputs from user 2
PR2. Correctly display a message such as “J.Clark (male) was born in 1989.” 1
PR3. Correctly calculate and display a user’s personalised number 4
PR4. Correctly set up a loop to allow a user to play the game again 2
PR5. Correctly calculate and display the total personalised numbers given when a 
user chooses to exit.
1
General Requirements (for each item there are only 3 possible marks: 100% or 50% or 0%)
General Item Mark
GN1. Program structure and layout
Clear and tidy (2). Somewhat messy but understandable (1). Messy (0.5)
2
GN2. Include name, ID, and brief introduction in the program’s header 2
GN3. Appropriate in-line comments 1
Assignment Raw Total: /15
Lateness Penalty: 
Assignment Final: /15
UTAS lateness penalty policy:
“Assignments submitted after the deadline will receive a late penalty of 5% of the original available mark 
for each calendar day (or part day) that the assignment is late. Late submissions will not be accepted more 
than 10 calendar days after the due date, or after assignments have been returned to other students on a 
scheduled date, whichever occurs first.”