Summer task 2013 (2.39 mb )

taxidermistplateΛογισμικό & κατασκευή λογ/κού

7 Νοε 2013 (πριν από 3 χρόνια και 5 μήνες)

78 εμφανίσεις

AS Computing




Name:

………….. …………….







St Brendan’s
Computing
Summer task

201
3




































St Brendan’
s AS Computing

Summer task

Summer 2013

jaz

last edit: 2013 6 22

page
1

of 12

Summer Task


is a course requirement

In addition to the other entry requirements you need to complete this task to be allowed onto the
AS computing course. Below you will

be guided to download and install the free programming
software used in the AS course and complete some exercises. First some background
information.

AS
Computing at St Brendan’s

The AS computing course
at St Brendan’s
follows the AQA syllabus and consist
s of both theory
and practical work. The theory work material is largely covered by the
Nelson Thorne’s
textbook

AQA Computing


by Kevin Bond and Sylvia Langfield. Practical work uses the Java
programming language. For more details on the whole course se
e:

Welcome to Computing
201
3
.ppt

Introduction to Java

Java Basics



do not worry if you do not
u
nderstand
this section
fully
(
you
can do all the work

below

without it)

Programming languages are typically written using text,
called source code, using a tex
t editor and translated, using
a compiler or interpreter, into executable machine language
code which runs on specific platforms (machine types).
Unlike many other programming languages Java source
code is first translated (compiled) into byte code which i
s
the same for different platforms. The Java Virtual Machine
(JVM) is software that translates (interprets) and executes
byte code on a particular platform. Byte code can be
thought of as machine language for the JVM software machine. The JVM allows Java s
ource
code to be translated to byte code that is the same for different machines (platform independent).


Java source code is held in .java files and compiled into byte code in .class files for the JVM to
execute.

[see
http://chortle.ccsu.edu/java5/Notes/chap05/ch05_1.html

to
ch05_5.html

for more detail]

Java Programming

In order to run a Java program the Java Runtime Environment (JRE) is required.

In order to write a Java program
a Java Development Kit (JDK) is required.


An Integrated Development Environment (IDE) is
useful software to help develop Java programs. Popular
IDEs are Eclipse, Netbeans and BlueJ. In the first year
at St Brendan’s we use BlueJ mostly.

Software install
ation

Use
the
guidance
in the next few pages
to download and
install the latest Java SE JDK 7 or Java
SE JDK 6

and then download BlueJ.


Note:
BlueJ require
s Java to be installed
already before it can be installed
.

St Brendan’
s AS Computing

Summer task

Summer 2013

jaz

last edit: 2013 6 22

page
2

of 12


1
Download and install Java

From
http://www.oracle.com/technetwork/java/javase/downloads/index.html

download the

Java JDK,
Java SE 7
u25

latest up
d
ate version (currently update 25
) JDK

Note:
some of
the screensh
ots

below

are from 2011 so
refer to an

earlier version but
the
process
should
look

similar

to
this
.



















Select Download JDK


(NOT JRE

or
with NetBeans or
other
)






















Accept license agreement and select
appropriate
download

for
your
operating system, for example
Windows x86



Save File to any suitable location and run to install downloaded file


St Brendan’
s AS Computing

Summer task

Summer 2013

jaz

last edit: 2013 6 22

page
3

of 12


Java installation should then be straight forward:




















(
Alternatively,
YouTube
tutorial 1 J
ava install:
http://www.youtube.com/watch?v=Hl
-
zzrqQoSE&feature=related

)


2 Download and install BlueJ



















From
http://www.blue
j.org/download/download.html

download BlueJ 3 latest version (currently 3.
1
.
0
)


Select appropriate
installation package


probably for Windows.



Save File to any suitable location and run to install
downloaded file



St Brendan’
s AS Computing

Summer task

Summer 2013

jaz

last edit: 2013 6 22

page
4

of 12


BlueJ installation should then

be straight forward:


From

your desktop
or start menu open BlueJ


Check version: Help


about BlueJ








Simple program using BlueJ

We shall now use the BlueJ IDE to develop a simple Java program to
say ‘Hello’.


In BlueJ select: Proj
ect


New Project. Create a project ‘Summer
project’ in a suitable location
-

Create


New Class


type HelloWorld
for class name
-

Ok.


Double click the HelloWorld class to open the code edit window (or right click


Open Editor).



Check have
new version
3.1.0

NB: Java is case sensitive

Double click
to type code

St Brendan’
s AS Computing

Summer task

Summer 2013

jaz

last edit: 2013 6 22

page
5

of 12


Delete all the

example code and type in the HelloWorld code as shown below, but with your own
name after author (and not anything in the dashed rectangles which are notes to help you).

Note:



Java comments do not affect how
a
program runs but are used to help program
mer so should
be used



Indent code to help readability (does not affect compilation / execution)
:
use
Edit
-

Auto
-
layout



Semi colon ; curly brackets {, } round brackets (, ) and square brackets [, ] must be used
correctly and are NOT interchangeable.



For li
ne numbers (in the code editor): Options


preferences


display line numbers.



BlueJ reference site:
http://www.bluej.org/



Click compile (you should get ‘Class compiled
-

no syntax
errors’
-

otherwise check lines 5

to 11 are correctly typed


Java
is case sensitive, and remember curly brackets and semicolon


Java is fussy!


Close the editor.

Right click the HelloWorld class

Select void main(String[] args)

Select Ok

The terminal window should contain
“Hello World
!” as output

as shown:


Note:

It is possible to write Java using a
normal text editor, and compile and run java programs using the Java SDK without need for an
IDE such as BlueJ by using the command line interface. You are not required to do so. But if yo
u
are interested to do this, see
Chortle chapter 7

or YouTube tutorial 2 running Java:
http://www.youtube.com
/watch?v=5u8rFbpdvds&feature=fvwrel
.


youTube reference links for installing BlueJ and a HelloWorld program,
zaychenok

Java Lesson 1&2:

http://www.youtube.com/watch?v=aqQefkprf3s
,
http://www.youtube.com/watch?v=l9nHHCgXBMk&feature=related


Now
you are ready

to start work. Allow at least 12

hours to complete
the
work that follows.

Java multi line comment

Java single line comments

Class name must be exactly the same as file name

Don’t
worry
about this line


just know it is
needed for now

Displays Hello World
message

St Brendan’
s AS Computing

Summer task

Summer 2013

jaz

last edit: 2013 6 22

page
6

of 12

U
ser input using Scanner with Progranimat
e & BlueJ

Browse to
http://www.progranimate.com/
. Launch Progranimate.
Start Progranimate (with
default Java_code selected as language). Open


run.

(
See problems section on how to run in
a
browser if needed.
)


To c
reate
a

flowchart (which generates
Java
code
)

do the following
:



Select
Variable
-

name: num
Passengers, Type: int, Add



Select
Variable
-

name: num
FullCoaches, Type: int, Add


… and similarly to declare int variables
num
ExtraCoach
Passengers

and
seats
OnACoach




Click Print button then
click
on Start ellipse to add Print component below the start. Type in

"number of passengers:

"

and select print.



Click Read button then on Print parallelogram to add read component below the Print. Type
in
num
Passengers


… and similarly to get the number of seats on a coach.




Click Assign. Type:
numFullCoaches = num
Passengers / seatsOnACoach



Click Assign. Type:
num
ExtraCoachPassengers

= num
Passengers % seatsOnACoach


… and print out how many full buses and how many passe
ngers on the last bus

(see code below)

[A
lternatively Load
CoachCalculator
.
prg



a copy is on the website with other
files
]

So that you should now have

the situation
shown
here
:






















Select Run. Type in

some data

such as 105

passengers a
nd 40

seats on a coach.

Notice
how

the variable
t
able tracks changes.


Now type (
or
copy

or file
-

export
) this code into BlueJ.

You need

an

extra line at the very

beginning to be able to use a Scanner:

import
java.util.Scanner;


Now
run as a program in
BlueJ and
t
est with some data.


You can use Progranimate to help with creating programs and solutions to the exercises below,
particularly those requiring input using a Scanner. But you are not required to use Progranimate.
NOTE:


/ gives integer division eg 15 / 6 = 2


% gives the remainder eg 15 % 6 = 3

St Brendan’
s AS Computing

Summer task

Summer 2013

jaz

last edit: 2013 6 22

page
7

of 12


Java
Work

Go to chortle site
http://chortle.ccsu.edu/CS151/cs151java.html

or
use
mirror site
http://programmedlessons.org/java5/index.html
. Go through chapters 8



11 and do as many
exercises and
quizzes as you need. Set aside at least six hours to work through these chapters and
more if you do more than a few of the exercises. After chapters 8


9c attempt question 1 be
low
(filling in answers 01 to 0
3
). After cha
pters 10


11 attempt question 2
, 3 and 4

be
low (filling in
answers 04 to 11
).


YouTube reference links to go with chortle reading above and exercises below:

Use of
Scanner (
but not BlueJ IDE)

http
://www.youtube.com/watch?v=mdOZzDKm8Ho


Bucky tutorials
(
use

Eclipse IDE

instead of BlueJ

but otherwise are relevant
)

Java Programming Tutorial
-

6
-

Getting User Input

http://www.y
outube.com/watch?v=5DdacOkrTgo&feature=relmfu


(OR on the new boston:
http://thenewboston.org/watch.php?cat=31&number=6

etc)

Java Programming Tutorial
-

7
-

Building a Basic Calculator



http://www.youtube.com/watch?v=2MjKuUTXa4o



StBrendan
(use

BlueJ Scanner with integer division

and remainder useful for que 2)



h
ttp://www.youtube.com/watch?v=Y5lBpaO6to4





Type your answers to the exercises below in your Electronic Answer Document.

You
must save
this document at regular intervals.




Question 1

Create

a class Exercise1 with the code below

(you can type
in or copy and paste)
:

public class Exercise1

{


public static void main (String[] args)


{


double km = 20, miles


miles = km * 5 / 8;


System.println(km + " kilometres is " + miles + " miles");


}//end main

}//end class


(a)
The p
rogram has two compilation errors. Correct these.










What you need to do

Modify the program so that

it
so the program compiles and runs









(
tip:
see EAD front sheet for
help
on pasting screenshots into EAD)


(b) (i) replace
miles = km * 5 /

8;

by

miles = 5
.0

/ 8

*

km;

compile and run


(ii) replace
miles = 5
.0

/ 8

*

km;

by

miles = 5 / 8

*

km;

compile and run




Explain

fully

the results obtained in running versions b(i) and (ii)
.
To gain full marks
you will need to
note

the relevance of da
ta types

(
Chortle chp 8,

9B)

(2 marks)


0 1

Evidence that you need to provide

Include the following in
your Electronic Answer Document.



Your corrected PROGRAM SOURCE CODE.



(2 marks)



SCREEN CAPTURE of program output in terminal window

(1 mark)

0 2

0 3

St Brendan’
s AS Computing

Summer task

Summer 2013

jaz

last edit: 2013 6 22

page
8

of 12


Question 2

Create

a class Exercise2 with the code below:


import java.util.Scanner;

//package needed to read from keyboard

public class Exercise2

{


public static void main (String[] args)


{


//declare S
canner and integer variables


Scanner sc = new Scanner(System.in);


int allMonths, years, partMonths;




//ask for age in months


System.out.print("Age in months: ");




//set allMonths to value typed in


//c
ode here




//calculate years from allMonths


//code here


//calculate partMonths from allMonths


//code here




//display message ab
out calculated years and months


//code here


}//end main

}//end class



Currently t
he program
prompts the user for a number of months but does not yet calculate
and output how many years and months this is equivalent to
.

For example when the user
types an input of 40 the program output should be:


Age in months: 40


40 months

= 3 years and 4 months










What you need to do

Modify the program so that

for an input number of months the
whole
years and months are
calculated and displayed


Test
your

program with age in months

values as follows.

Test 1:


9

Test 2:

24

Test 3:


31














0 4

Evidence that you need to provide

Include the following in your Electronic Answer Document.



Your completed PROGRAM SOURCE CODE.


(6 marks)



SCREEN CAPTURE for Test 1




(1 mark)



SCREEN CAPTURE for Test 2




(1 mark)



SCREEN CAPTURE for Test 3




(1 mark)


0 5

0 6

0 7

St Brendan’
s AS Computing

Summer task

Summer 2013

jaz

last edit: 2013 6 22

page
9

of 12

Question 3

Create

a class
PizzaCost

with the code below:





















Currently t
he program
prompts the user for
how many share a pizza

but
the pizza price is set
at £10.95 and does not allow a user to input a pizza price or

the number of pizzas
.










What you need to do

Modify the program so that

the user is
prompted for the number of pizzas and
the price of each pizza as well as how
many people are sharing and outputs
the amount each person has to pay for
an equal sha
re.

Do not worry about the
number of decimal places in your
answer


this will be dealt with later.


Test your program
as follows
.

Test
:
4 pizzas
, £8.50 for each pizza and 8 people sharing














0 8

Evidence that you need to provide

Include the following in yo
ur Electronic Answer Document.



Your completed PROGRAM SOURCE CODE.


(5 marks)



SCREEN CAPTURE for the test




(2 marks)


0 9

St Brendan’
s AS Computing

Summer task

Summer 2013

jaz

last edit: 2013 6 22

page
10

of 12

Question 4

Create

a class BillChange class with the

code below:



























This program contains 3 errors: 2 syntax errors and 1 semantic error.


What you need to do

Modify the program
to
calculate the change

for
a payment of a

random bill

(up to £100).


Test
:
Test your program with
an appr
opriate payment for your random bill
.














1 0

Evidence that you need to provide

Include the following in your Electronic Answer Document.



Your completed PROGRAM S
OURCE CODE.


(3 marks)



SCREEN CAPTURE for Test




(1 mark)

1 1

St Brendan’
s AS Computing

Summer task

Summer 2013

jaz

last edit: 2013 6 22

page
11

of 12

Theory work

Set aside at least five hours to view
the

lecture and work through the tutorial chapters below.


Listen to MIT introductory lecture, Lec 1 | MIT 6.00 Introduction to Computer Science and
Pr
ogramming, Fall 2008:

http://www.youtube.com/watch?v=k6U
-
i4gXkLM&feature=related

(54
mins
,

but

skip minutes
: 0


4.35 and 7.15


16.15
). Do not worry if you find it difficult to fo
llow in
places and note t
he
programming
language introduced
briefly
is Python not Java but it is still a good
introduction to what computing is about and relevant to our

course. Then answer question

4
below:


Read through
http://chortle.ccsu.edu/java5/index.html

chapters 1 to 4. Try the quizzes and
flashcards.

Then work through the rest of the questions below.


Type your answers to the exercises below in your Electronic Answer Document.

You
must sav
e
this document at regular intervals.



Question 5


Joe knows he needs to find the shortest route

from Bath to Milton Keynes. Ann knows
Dijkstra’s algorithm/method for finding the shortest path between any two locations.
State

and
explain

which person h
as
imperative

knowledge and which has
declarative

knowledge
in this situation










(1 mark)


Two

students want to sum up the integer variables x and y using Java.

Freda writes
int z = x + y

and forgets to place a semicolon at the end of the statement

George writes
int z = x


y;

and has wrongly put a minus instead of a plus. Both have made
errors. State and explain who has made a
syntax

error and who has made a
semantic

error













(1 mark)


How many primitives did Turing use to pro
g
ram anything

that can be programmed
?














(1 mark)


Question 6

(based on Chortle
Chapter 1)


Explain what
software

refers to for a computer system




(1 mark)


Explain what
bus

refers to for a computer system





(1 mark)


State which out of Main Memory (RA
M) and Secondary Memory (also called secondary
storage or auxiliary storage) is volatile
. Explain what this means
.



(2

mark)


An example computer hardware
network
device is a
NIC. What does NIC stand for and what
is a NIC used for
?









(1 mark)




W
here are programs and data kept for long
-
term storage?




(1 mark)


Where is a program and its data kept whilst the program runs?



(1 mark)




1 2

1 3

1 5

1 6

1 8

1 9

2 0

1 7

1 4

St Brendan’
s AS Computing

Summer task

Summer 2013

jaz

last edit: 2013 6 22

page
12

of 12


Question
7

(based on Chortle Chapter 2
)


What does binary mean?








(1 mark)


What is a bit?










(1
mark)



What does one Hertz mean?








(1 mark)



Question
8

(based on Chortle Chapter 3
)


There are many ways in which a bit can be
implemented.

State 2 ways.


(1 mark)


How many bits are there in one byte?







(1 mark)


What
are

2
20
bytes and 2
30

bytes called respectively?





(1 mark)


A particular digital image is 1024 rows by 1024 columns, and each location (pixel) is
represented by 16 bits. How many megabytes are
used to store
this

image?


(1 mark)


How many bytes can a 32 bit processor read

from or write to memory at one time?

(1 mark)



Question
9

(based on Chortle Chapter 4
)


Is Java a high or low level programming language?





(1 mark)


Software X is used to translate the whole source code of a high level language program and
save
s

it
to a binary (machine code) file that can then be run.


Which type of translator is
software X, a compiler

or interpreter?







(1 mark)




End of questions


Please complete the feedback survey at the end of the EAD


Remember to
submit
the completed
EAD


see EAD for details



Optional extras
-

the future?



U
biquitous

computing:

Youtube (BBC4) Michio Kaku
-

The Intelligence Revolution



Jobs
:
TED

talk: Andrew M
cafee
-

future jobs


2 1

2 2

2 3

2 4

2 5

2 6

2 7

2 8

2 9

3 0