Vous êtes sur la page 1sur 5

Remedial Package 1: Problem Solving

If you find it difficult to follow any of the topics listed in a module, please go through the corresponding online tutorial links listed. On successful completion of the topics mapping to ILP curriculum in the links provided, you can try the practice exercise set. After completing the exercises your tech lead/stream owner will check your learning progress and decide on your clearance from the Remedial Package.

Module 1: Programming Basics


Numeric computations, conditional processing, methods, iterations and basic text processing. Programming / Problem Solving Suggested Learning Numeric Computations http://www.functionx.com/csharp3/Lesson02.htm http://www.functionx.com/csharp3/Lesson03.htm http://www.functionx.com/csharp3/Lesson06.htm Conditional Processing http://www.functionx.com/csharp3/Lesson09.htm http://www.functionx.com/csharp3/Lesson10.htm http://www.functionx.com/csharp3/Lesson11.htm Routines/ Methods http://www.functionx.com/csharp3/Lesson07.htm Basic Iterations http://www.functionx.com/csharp3/Lesson12.htm Basic Text Processing http://www.functionx.com/csharp3/Lesson25.htm

Practice Exercises:
1. Write a console application that obtains four int values from the user and displays the product. Hint: you may recall that the Convert.ToDouble() command was used to covert the input from the console to a double; the equivalent command to convert from a string to an int is Convert.ToInt32(). 2. If you have two integers stored in variables var1 and var2, what Boolean test can you perform to see if one or the other (but not both) is greater than 10? Write an application that includes the logic from Exercise 1, obtains two numbers from the user, and displays them, but rejects any input where both numbers are greater than 10 and asks for two new numbers. 3. Write a console application that accepts a string from the user and outputs a string with the characters in reverse order. 4. Write a console application that places double quotation marks around each word in a string 5. Write a program in C# that take string input, and print its number of characters. 6. An old-style movie theater has a simple profit function. Each customer pays $5 per ticket. Every performance costs the theater $20, plus $.50 per attendee. Develop the function total-profit. It consumes the number of attendees (of a show) and produces how much income the attendees produce. 7. The United States uses the English system of (length) measurements. The rest of the

world uses the metric system. So, people who travel abroad and companies that trade with foreign partners often need to convert English measurements to metric ones and vice versa. Here is a table that shows the six major units of length measurements of the English system:

Develop the functions inches->cm, feet->inches, yards->feet, rods->yards, furlongs->rods, and miles->furlongs 8) Generate the Fibonacci sequence. Starting with 0, 1 add them up then take the result and add it to the last number and repeat. Answer should look like: 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 9) Two positive integers are friendly if each one is equal to the sum of the divisors (including one and excluding the number itself) of each other. 220 and 284 are friendly. Write a program to check if two numbers are friendly.

Module 2: Searching Sorting


Programming / Problem Solving Suggested Learning Searching and Sorting http://www.functionx.com/csharp3/Lesson21.htm

Practice Exercises:
1) Write a program in C Sharp that take a sentence as input, and show the number of "a" used in the sentence. 2) Write a program in C# that take 5 integers, and sort them.

Module 3: OO Programming
Information Types, Class Collaboration and relationships. Suggest Programming / Problem Solving Suggested Learning Information Types http://www.functionx.com/csharp3/Lesson04.htm http://www.functionx.com/csharp3/Lesson13.htm http://www.functionx.com/csharp3/Lesson17.htm

Practice Exercices: 1) Point Class Create a point class with appropriate constructors, properties It should have a method to calculate the distance from another point Test the Point class in another driver class. 2) Complex Number Create a class called Complex for performing arithmetic with complex umbers. Complex numbers have the form Real Part + Imaginary Part * i, where i is sqrt (-1). Write a program to test your class. Use floating-point variables to represent the private data of the class. Provide a constructor that enables an object of this class to be initialized when it is declared. Provide a no-argument constructor with default values in case no initialized are provided. Provide public methods that perform the following operations: Add two Complex numbers: The real parts are added together and the imaginary parts are added together. Subtract two Complex numbers: The real part of the right operand is subtracted from the real part of the left operand, and the imaginary part of right operand is subtracted from the imaginary part of the left operand. Print Complex numbers in the form (a, b), where a is the real part and b is the imaginary part.

Module 4: Working with Collections


Suggest Programming / Problem Solving Suggested Learning Working with Collections http://www.functionx.com/csharp3/Lesson28.htm http://www.functionx.com/csharp3/Lesson29.htm http://www.functionx.com/csharp3/Lesson30.htm http://www.functionx.com/csharp3/Lesson31.htm

1. Write an application that receives the following information from a set of students: Student Id: Student Name: Course Name: Date of Birth: The application should also display the information of all the students once the data is entered. Implement this using an Array of Structs. 2. Create a stack of strings with methods to Pop and Push. 3. Create a program which stores order details for a particular order id. Use Dictionary in the collections namespace

Module 5: Layering Fundamentals: Interfaces / Polymorphism/Delegates

Programming / Problem Solving Suggested Learning Interface Composition Polymorphism http://www.functionx.com/csharp3/Lesson15.htm Delegates http://www.functionx.com/csharp3/Lesson16.htm

Final Assignment
Step 1: Lookup the System.DateTime structure. This type contains a large amount of functionality that allows a user to perform all sorts of interesting operations with dates and times. Use System.DateTime along with System.Console to implement a simple C# program that does the following: Ask the user for their birthday. It will probably easiest to ask year, then month, then day rather than parsing a combined string reliably. Calculate the age of the user. Check to see if the age of the user is impossible. For example, if the user is not yet born, output an error message. If the user claims to be 135 years old, then let them know that's not possible. Output the age of the user to the console. If it is the user's birthday, output a nice message.

Step 2
Create a class called Person. Populate the Person class with the following properties to store the following information: First name Last name Email address Date of birth Add constructors that accept the following parameter lists: All four parameters First, Last, Email First, Last, Date of birth Add read-only properties that return the following computed information: 1) Adult - whether or not the person is over 18 2) Birthday - whether or not today is the person's birthday 3) Screen name - a default screen name that you might see being offered to a first time user of AOL or Yahoo (e.g. John Doe born on Feburary 25th, 1980 might be jdoe225 or johndoe022580) Make sure that your class has the proper documentation. This means inline comments.

Step 3

Create an interface called Payable. This is the interface that will be used by the accounting department's software (which you are not responsible for authoring) for all things that they need to write checks for. The Payable interface should contain three functions: Retrieve amount due Add to amount due Payment address Derive an Employee class from the Person class. The Employee class should add the following properties: Salary Mailing address In addition, the Employee class should implement the Payable interface. The implementation of the functions specified in the Payable interface should make sense. In other words, the payment address should be the mailing address of the employee. In order to make this work right, you will need to allocate an internally protected state variable that keeps track of the amount of money due. This state variable will obviously be modified by the functions defined in the interface. You can of course, try to do this with a property and add this property to the Payable interface.

Vous aimerez peut-être aussi