/
Telerik School Academy Telerik School Academy

Telerik School Academy - PowerPoint Presentation

mitsue-stanley
mitsue-stanley . @mitsue-stanley
Follow
399 views
Uploaded On 2015-10-13

Telerik School Academy - PPT Presentation

Meeting 1 November 2010 Intro to C Homework Assignments Svetlin Nakov Telerik Corporation wwwtelerikcom http schoolacademytelerikcom Prepare IT Test Questions Prepare IT Test Questions ID: 159355

write program students linq program write linq students class overview array language define http methods console create finds prints

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "Telerik School Academy" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

Telerik School Academy

Meeting #1 – November 2010 – Intro to C#Homework Assignments

Svetlin Nakov

Telerik Corporation

www.telerik.com

http://

schoolacademy.telerik.comSlide2

Prepare IT Test QuestionsSlide3

Prepare IT Test Questions

Prepare at least 20 questions for preparation for the National Olympiad's IT testPrepare at least one question for each category from the official conspectusCategories are officially published at

http://edusoft.fmi.uni-sofia.bg/documents/Conspect0910.pdfFollow strictly the IT test template: IT-Test-Questions-Template.pptx

3Slide4

.NET Framework OverviewSlide5

.NET Framework

Install at home .NET Framework 4 and Microsoft Visual Studio 2010 (or VS Express)Write a "Hello World" application in C#

Install at home the .NET ReflectorPlay with it by decompiling the

System.Console class

5Slide6

C# Language Overview

C#Slide7

C# Language Overview

Write a C# program that prints all

numbers 1…100.

Write a program that prints all the numbers from 1 to N, that are not divisible by 3 and 7.

Write a program that reads from the console a sequence of N integer numbers and returns the minimal and maximal of them.

Write a program that calculates N!/K! for given N and K (1<N<K).

Write a program that reads a number N and calculates the sum of the first N members of the sequence of Fibonacci: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, …7Slide8

C# Language Overview (2)

Write a program that finds the maximal sequence of equal elements in an array.

Example: {2, 1, 1, 2, 3, 3,

2, 2, 2, 1}  {2, 2, 2

}.

Write a program that finds the maximal increasing sequence of elements in an array. Example: {3,

2, 3, 4, 2, 2, 4}  {2, 3, 4}.Write a program that finds the most frequent number in an array. Example: {4, 1, 1, 4, 2, 3,

4, 4, 1, 2,

4, 9, 3}  4 (5 times)Write a program that finds all prime numbers in the range [1...10 000 000]. Use the

sieve of Eratosthenes

algorithm

(find it in Wikipedia

)

.

8Slide9

C# Language Overview (3)

Write a program that prints to the console which day of the week is today. Use

System.DateTime

.

Write methods that calculate the surface of a triangle by given: side and an altitude to it; three

sides; two sides and an angle between them. Use System.Math.

Write a program that enters file name along with its full file path (e.g. C:\WINDOWS\win.ini), reads its contents and prints it on the console. Find in MSDN how to use System.IO.File.ReadAllText(…). Be sure to catch all possible exceptions and print user-friendly error messages.9Slide10

C# Language Overview (4)

Write a program that downloads a file from Internet (e.g.

http://www.devbg.org/img/Logo-BASD.jpg) and stores it the current directory. Find in Google how to download files in C#. Be sure to catch all exceptions and to free any used resources.

Write a program that reads a string, reverses it and prints it on the console. Example: "sample"

 "elpmas

".Write a program that reads from a text file a list of strings, sorts them and prints them on the console in alphabetical order.

10Slide11

C# Language Overview (5)

Write a program that finds how many times a substring is contained in a given text (perform case insensitive search).

Example: The target substring is

"in".

The text is as follows:

The result is: 9.

We are living in an yellow submarine. We don't have anything else. Inside the submarine is very tight. So we are drinking all the day. We will move out of it in 5 days.

11Slide12

C# Language Overview (6)

Write a program that parses an URL address given in the format:

and extracts from it the

[protocol],

[server]

and [resource] elements. For example from the URL

http://www.devbg.org/forum/index.php the following information should be extracted: [protocol] = "http" [server] = "www.devbg.org"

[resource] = "/forum/index.php"

[protocol]://[server]/[resource]

12Slide13

C# Language Overview (7)

Write a program that finds in given

array of integers (all belonging to the range [0..1000]) how many times each of them occurs.Example: array = {3, 4, 4, 2, 3, 3, 4, 3, 2}

2  2 times

3 

4 times4  3 times

Write a program that reads a text file and finds all words used in it and how many times each word occurs. Assume that words differing in character casing only are the same.13Slide14

Object-Oriented Programming in C#

C#Slide15

OOP in C#

Define

a class

Human with first name and last name. Define new class

Student which is derived from

Human and has new field – grade. Define class

Worker derived from Human with new field weekSalary and work-hours per day and method MoneyPerHour() that returns money earned by hour by the worker. Define the proper constructors and properties for this hierarchy. Initialize an array of 10 students and sort them by grade in ascending order. Initialize an array of 10 workers and sort them by money per hour in descending order.

15Slide16

OOP in C# (2)

Define abstract class

Shape

with only one virtual method CalculateSurface() and fields

width

and height. Define two new classes

Triangle and Rectangle that implement the virtual method and return the surface of the figure (height*width for rectangle and height*width/2 for triangle). Define class Circle and suitable constructor so that on initialization height must be kept equal to

width and implement the CalculateSurface()

method. Write a program that tests the behavior of the CalculateSurface() method for different shapes (Circle

,

Rectangle

,

Triangle

) stored in an array.

16Slide17

OOP in C#

(3)Create a hierarchy

Dog,

Frog,

Cat,

Kitten, Tomcat and define suitable constructors and methods according to the following rules: all of this are Animals. Kittens and tomcats are cats. All animals are described by age, name and sex. Kittens can be only female and tomcats can be only male. Each animal produce a sound. Create arrays of different kinds of animals and calculate the average age of each kind of animal using static methods. Create static method in the animal class that identifies the animal by its sound.

17Slide18

Lambda Expressions, Extension Methods and LINQ

LINQSlide19

LINQ

Create a class student with properties

FirstName, LastName

, FN,

Tel,

Email, Marks

(a List<int>), GroupNumber. Create a List<Student> with sample students. Select only the students that are from group number 2. Use LINQ query. Order the

students by FirstName.Implement the previous using

the same query expressed with extension methods.Extract all students that have email in abv.bg. Use string methods and LINQ.

Extract all

students

having phones

in

Sofia (staring with

02

).

Use

LINQ and regular expressions.

19Slide20

LINQ (2)

Select all students that have at least one mark Excellent (6) into a new anonymous class that has properties –

FullName and

Marks. Use LINQ.

Write down a similar program that extracts the students with exactly

two marks "2". Use extension methods.Extract all

Marks of the students that enrolled in 2006. (The students from 2006 have 06 as their 5-th and 6-th digit in the FN).Create a class Group with properties GroupNumber and

DepartmentName. Introduce a property Group in the

Student class. Extract all students from "Mathematics" department. Use the Join operator.20Slide21

LINQ (3)

Write a program to return the string with maximum length from an array of strings. Use LINQ.

Create a program that extracts all students grouped by GroupName and then prints them to the console. Use LINQ.

Rewrite the previous using extension methods.

21Slide22

Submission Instructions

and DeadlineSlide23

Submission Instructions

Homework solutions should be submitted at the following Web site:http://nakov.devbg.org/schoolacademy-uploads/

Solutions should be packed in a single ZIP or RAR archive with a following structure

IT-Test – directory

for the IT test

CSharp – directory for the C# solutions

OOP – directory for the OOP solutionsLINQ – directory for the LINQ solutions

23Slide24

Further Instructions

The deadline for the homework is:A week before the next training session

Everybody is free to use help from friends, teachers or InternetSubmission of the same work by different authors may result in a disqualificationAsk your questions in the Telerik School Academy official discussion group:

http://groups.google.com/group/it-olymp

24Slide25

Homework Assignments

Questions?

?

?

?

?

?

?

?

?

?

?

http://schoolacademy.telerik.com