Presentation is loading. Please wait.

Presentation is loading. Please wait.

Copyright ©2004 Virtusa Corporation | CONFIDENTIAL.Net Assignments K. R. C. Wijesinghe Trainer Virtusa Corporation.

Similar presentations


Presentation on theme: "Copyright ©2004 Virtusa Corporation | CONFIDENTIAL.Net Assignments K. R. C. Wijesinghe Trainer Virtusa Corporation."— Presentation transcript:

1 Copyright ©2004 Virtusa Corporation | CONFIDENTIAL.Net Assignments K. R. C. Wijesinghe Trainer Virtusa Corporation

2 2 Copyright ©2004 Virtusa Corporation | CONFIDENTIAL C# I/O Write a console mode program to input the width and height of a rectangle as floating points values and display the area of it

3 3 Copyright ©2004 Virtusa Corporation | CONFIDENTIAL C# Conditions Write a program to input the marks of a student and display "Pass" if the marks is greater that 50 and "Fail" otherwise

4 4 Copyright ©2004 Virtusa Corporation | CONFIDENTIAL Loops Write a program input a number and display its multiplication table as follows, Enter N: 4 Multiplication Table of 4 1 x 4 = 4 2 x 4 = 8 3 x 4 = 12 4 x 4 = 16 5 x 4 = 20 6 x 4 = 24 7 x 4 = 28 8 x 4 = 32 9 x 4 = 36 10 x 4 = 40

5 5 Copyright ©2004 Virtusa Corporation | CONFIDENTIAL Classes Write a class with the name "MulTable" with the following public methods (you can have any private methods and member variables) public MulTable( ); public MutTable(int N); public void SetMultiplicationFactor(int N); public int GetMultiplicationFactor(); public void PrintTable( ); Write a class with a main method to display the multiplication table using this class

6 6 Copyright ©2004 Virtusa Corporation | CONFIDENTIAL Properties Replace the SetMultiplicationFactor and GetMultiplicationFactor methods with the property MultiplicationFactor Change the main method accordingly

7 7 Copyright ©2004 Virtusa Corporation | CONFIDENTIAL Arrays Write a class with the name IntList which can store N number of integers (N is given as a parameter of the constructor) and contains the following methods public IntList(int N); // Constructor, creates an array to hold N numbers void Init(int n); //Initialize all the numbers to n void AddNumber (int i, int n); // Add number n to i th position int GetTotal( ); // Get the total of all the numbers in the list int GetAverage ( ); // Get the average of all the numbers in the list Write a class with main method to find the total and average of set of integers using this class

8 8 Copyright ©2004 Virtusa Corporation | CONFIDENTIAL Interfaces Write an interface IOwner with the following method string GetOwner(); void TransferOwnerSheip (sting NetOwner); Write a class Car that implements IOwner, with following methods public Car(sting brand, string number, string owner); public string GetNumber( ); public string GetBrand( ); public string GetOwner( ); public TransferOwnerSheip (string NewOwner); Write a class Cat that implements IOwner, with following methods public Cat (string name, string owner); public string GetName( ); public string GetOwner( ); public TransferOwnerSheip (string NewOwner); Write a class with a main method to add 2 cats and 3 cars to an array of IOwner and print the owner of each of them

9 9 Copyright ©2004 Virtusa Corporation | CONFIDENTIAL Collections Rewrite the IntList class to store any number of integers (not a predetermined number, given in the constructors) using ArrayList. Replace the AddNumber(n,i) method with AddNumber (n) method, which will simply add the number at the end of the list

10 10 Copyright ©2004 Virtusa Corporation | CONFIDENTIAL Inheritance Write a class with the name "Account" to represent bank account. This class must have the following public methods public Account(string AccountNumber, float interest_rate); public void Deposite (float amount); public bool Withdraw (float amount); //Must return false if the // amount is greater that the balance public void AddInterest( ); // This method can be called any time // However this method must be called before deposit, withdraw or get balance This class must have public read-only property "Balance" which gives the account balance public property "InterestRate" which can be used to get and set the current interest rate Add Interest method must Check how long it has been since the calculation of the last interest Calculate the interest for that period Add that amount to the account balance

11 11 Copyright ©2004 Virtusa Corporation | CONFIDENTIAL Inheritance 2 Write another class "JanaJayaAccount" derived form the type account This account gives a 5% additional bonus if the balance is greater than 500000/= at the time of interest calculation. Write an AccountManager class which will store a list of each of these accounts. This class must have the following public methods void AddNormalAccount(string AccountNumber, float interest_rate); void AddJanaJayaAccount(string AccountNumber, float interest_rate); void Deposite(string AccountNumber, float amount); bool WithDraw(string AccuntNumber, float amount); void AddInterestToAllAccounts(); float GetBalance(string AccountNumber); Write a class with main method, which contains a UI to add accounts of required type deposit withdraw get account balance

12 12 Copyright ©2004 Virtusa Corporation | CONFIDENTIAL Exceptions Rewrite the Deposit and Withdraw methods to throw an exception if a negative amount is attempted to deposit or withdraw Rewrite the main method to catch this exception and display an error message

13 13 Copyright ©2004 Virtusa Corporation | CONFIDENTIAL Reflection Create a library assembly with an Interface named IMyAddin which contains the following method void Execute(); Create another library assembly with a two classes that implements this interface (Execute method can contain anything that you like) Write an executable assembly which will load the above assembly (containing two classes) in to the domain search for the types that implements IMyAddin interface invoke the "Execute" method of each of them.

14 14 Copyright ©2004 Virtusa Corporation | CONFIDENTIAL GAC Create a library project Write a class Hello which contains only one method SayHello( ) which will print the message "Hello world" Create a console application project which uses this class to print the message "Hello world" Copy both the exe and the dll files into a same directory and run the exe file Now delete the dll file and see what happens Install the dll file to GAC Now run the exe file that does not have a dll file and see that happens

15 15 Copyright ©2004 Virtusa Corporation | CONFIDENTIAL Trace Rewrite the MulTable class, so that it will sent the debug information to a text file like, Print Table Printing line (multiplying by 1) Printing line (multiplying by 2) Printing line (multiplying by 3) Printing line (multiplying by 4) Printing line (multiplying by 5) Printing line (multiplying by 6) Printing line (multiplying by 7) Printing line (multiplying by 8) Printing line (multiplying by 9) Printing line (multiplying by 10) End table


Download ppt "Copyright ©2004 Virtusa Corporation | CONFIDENTIAL.Net Assignments K. R. C. Wijesinghe Trainer Virtusa Corporation."

Similar presentations


Ads by Google