Demo 11
Palautus 31.3. klo 11:59 (huom poikkeuksellinen ajankohta)
Practise exam
The points after the tasks (e.g. 6p) mean the points you will get the from this practise exam. Actual demo points are counted and shown like before so mostly 1p per task (2 points on task 1-2).
Remember the tests, comments and code writing conventions in this practise exam as well as in the real one. Lack of documentation and disregard of code writing conventions will lead to reduced points.
The purpose of this practise exam is to simulate the actual one, so it is adviced to begin by writing the code using pen and paper. Then save your answer in TIM exactly as you wrote it down on the paper. Afterwards you may correct your answer using Visual Studio and save the correct answer to TIM.
The final exam will not have Ville, PP or Guru assignments.
Your time usage this week (0.5 p.)
The hours were reset 12.3. 14:00. Please write down your time usage again.
Submitting time usage grants 0.5 points. Set Custom Points.
This includes all course-related work during the week (lectures, reading the course material, completing the exercises etc.) You may update the hours along the week in order to better keep track of your time usage.
Veikko Mannisen ja Heidi Lötjösen tutkimuskysely
Vastaa Veikko Mannisen ja Heidi Lötjösen tutkimuskyselyyn ja sen jälkeen kirjoita alle teksti "Olen tehnyt kyselyn".
Kysely koskee ohjauksia ja niistä saamiasi kokemuksia sekä hyötyjä. Voit toki vastata kyselyyn vaikka et olisi ohjauksiin osallistunutkaan.
Laita itsellesi yksi piste Set Custom Points-toiminnolla.
Task 1-2*
Set custom points between 0 -- 2.
The Main calls functions EtsiToiseksiSuurin
which finds and returns the second largest number in the integer table brought as parameter. The subroutine is NOT allowed to sort the table.
What notable special cases might occur. Define how they are handled.
The class and the Main method are given, but hidden.
Example:
- Parameter table:
3, 1, -7, 9, 15, 8
- Function returns
9
If you wish to test your solution using comtest, note that classname is D11_T1
. Note the comtest syntax example given below.
/// <example>
/// <pre name="test">
/// D11_T1.ToiseksiSuurin(new int[] {}) === 0;
/// </pre>
/// </example>
Tehtävä 3
Vastaa alla oleviin kysymyksiin. Huomaa, että näissä kysymyksissä on vain yksi vastausyritys. Kuhunkin kysymykseen on tasan yksi oikea vastaus.
Task 3
Write using
clauses, class definition and Main
method on this task. You can leave Main
empty or call one of the functions given below.
A bus drives around in the city. On each stop it drops off passengers and gets new ones in.
Create a function Passengers
, with the following parameters:
int initialPassengers
, which tells the amount of passengers in the bus before the bus has visited a single stop.
List<int[]> busStops
, which is a list of bus stops. each stop is a table of integers (int[]
), the first element of which tells the number of new passengers and the second element indicates the number of passengers who exit the bus.
The function returns the number of passengers remaining in the bus after it has finished its route. Note that the number of passengers is not allowed to go below zero at any point of the journey. The return value can not be below zero either.
Task 4 Function call
Explain using your own words what happens during a function call. Discuss a function having two parameters. When is each variable created and destroyed? When calling a function what is the difference between objetc variables and basic variables (bool, char, int, double
) ? (6 p)
Task 5. Remove
Write a function Poista(jono, kirjain)
, where the following test cases pass. Types you need to think of yourself. As well as how <- is implemented. Write tests for the function and a Main which test how the function works. (6 p.)
TYPE jono <- "kissa istuu puussa"; // initializes jono
Poista(jono, ' ') === 2; jono.ToString() === "kissaistuupuussa";
Poista(jono, 'u') === 4; jono.ToString() === "kissaistpssa";
Poista(jono, 'k') === 1; jono.ToString() === "issaistpssa";
Poista(jono, 'a') === 2; jono.ToString() === "issistpss";
Poista(jono, 's') === 5; jono.ToString() === "iitp";
Poista(jono, 'x') === 0; jono.ToString() === "iitp";
Task 6. Theory
Answer the following questions with few lines and/or using an example (gather max. 6p worth of tasks):
a) How a C# program is compiled and run using command line? What if it needs a library? (2 p)
b) Count (write your calculations) the values of the following binary numbers as a decimal number. What assumptions did you make? (2 p.)
0100 0101 0011 1111 1000 0001
c) Let’s assume 8-bit negative integers are in the second complement form. In this system, what would be the number minus five (-5) in bit form. (1 p.)
d) Binary decimal number 1001.1110 as a base-10 number. (1 p.)
e) Explain how a List is better than a regular table? How is it inferior? (2 p.)
f) What's the difference between String
and StringBuilder
-classes? (1 p.)
g) Write down the value of 34/7
in C#?
Write down the value of 34%7
in C#. (1 p.)
h) What does it mean for an object to turn into garbage? (1 p.)
V1
Do Ville-tasks: 10.1, 10.2. (Ville-task points are not counted in the exam. They are only here for extra practise.)
Remember: Ville user manual
B1-3
Create a program which asks the users name and then encrypts it to a picture of a user so that at some point in the picture the name (in ASCII code) is written instead of the RGB values. Tip: Jypeli methods Image.GetDataUInt()
, Image.SetData()
and Color.PackRGB()
can be helpful.
G1-2
Euler problem 206. One point if the program runs for less than a minute. Second point if it is "super-fast" (counted in milliseconds). I might not be able to get the super-fast time myself :-).
These are the current permissions for this document; please modify if needed. You can always modify these permissions from the manage page.