Vous êtes sur la page 1sur 2

15/11/2010 Assignment 2

Java Programming, Assignment 2


To be submitted by midnight on Friday, 3rd December, 2010

Exercise 1 --- Statistical Analysis --- 20 Marks


If we have a set of measurements x i we can analyse them and find the mean value which gives the average
measurement, and the standart deviation s, which shows the amount by which measurements are likely to
differ from the mean. In other words, the standart deviation indicates the spread of the measurements.

The mean of the set of measurements x i (i=1 to n) is defined to be

and the formula for standart deviation is

Write a class Stats that

a) reads a set of numbers from the command line, converts them to doubles, stores them in an array of
doubles and displays them;(3 Marks)

b) calculates the mean value (5 marks) and standard deviation (7 marks) of the array in separate methods
(which accept an array as a parameter) and displays the result.

The output should be like:

You have entered the data: 18 94 128 59 97


Mean = 79.2
Standard deviation = 42.04402

c) You get 5 marks if you use try{} and catch{} blocks to catch different types of Exceptions.

Exercise 2 --- Teletraffic--- 30 marks


In the Teletraffic theory you can calculate a probability of conjection (or a probability that an arriving call will
be lost) using the formula:

where N- is the number of trunks (system capacity), A- is a traffic intensity (measured in Erlangs) calculated
with the formula:
A = number_calls_per_hour x average_call_length / 60

1. You will need to write a class TeletrafficFrame that creates a Frame like this:

F:/Teaching/java/…/ass2_2010.html 1/2
15/11/2010 Assignment 2

After entering initial values for the number of trunks, number of calls, the average call length and pressing the
"OK" button, your program should calculate the probability of conjection and display the result ( use a
JLabel). (8 Marks)
2. You should provide another class ProbConj for calculating the probability, using the numbers entered.
(You will pass them as parameters for a constructor of the class ProbConj). (12 Marks)
3. You get 10 marks if your program contains try{} and catch{} blocks to catch Exceptions, when a wrong
format number is entered, and as the result of this, a Dialog frame appears reporting an error. Like this:

Now if you press the Dialog button "OK", the Dialog Frame disappears, all the fields in the main frame are
cleaned up, and it is ready to accept new numbers.

Check how the probality changes if you have only 4 trunks, an increased number of calls up to 1800 and an
increased length of a single call up to 10 min. Make sure that all the numbers entered into the frame fileds are
positive! Note, that 0!=1 . You will need this for your calculations.

Method of submission
You have to submit all source (Java) files electronically via Blackboard.
Try to write well designed programs with lots of comments to make them user-friendly.

F:/Teaching/java/…/ass2_2010.html 2/2

Vous aimerez peut-être aussi