Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
149 views

C# Assignment 1

1. Design a C# method that adds 5 integers from keyboard input and returns the result and a flag indicating success or error. 2. Design a C# class to store network packets in a queue, with properties like ID, source IP, and destination IP. Overload methods to avoid duplicates and print details. 3. Design a C# program with a Student structure containing properties like USN, name, marks, and branch as an enum. Include a constructor and a method to increase ISE student marks by 10%.

Uploaded by

Brahmesh Mandya
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
149 views

C# Assignment 1

1. Design a C# method that adds 5 integers from keyboard input and returns the result and a flag indicating success or error. 2. Design a C# class to store network packets in a queue, with properties like ID, source IP, and destination IP. Overload methods to avoid duplicates and print details. 3. Design a C# program with a Student structure containing properties like USN, name, marks, and branch as an enum. Include a constructor and a method to increase ISE student marks by 10%.

Uploaded by

Brahmesh Mandya
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

1.

Design a C# method AddInts( ) to add 5 integers that are read from the keyboard and send the result and a
flag (true or false) indicating successful addition or an error to the calling program, say Main( ). You must
use appropriate parameter passing mechanism.
2. Design a C# class for storing the packets in a router buffer, which is normally implemented as a Queue.
The packet is an object whose structure is as follows:
<Packet_ID, Host_IP_Addr, Dst_IP_Addr>
Your class should support printing of packet details and avoid storing of duplicate packets in the Queue by
overloading ToString( ) and Equals( ).
3. Design a C# program to design a structure:
Student<USN, Name, Marks, Branch>
Here, Branch is of type enum, with members <CSE, ISE, EC, EE, IT>.
Add appropriate constructor and also a method to hike the marks by 10% to only ISE students. Show
creation of some student objects and the way to call these methods.
4. Write a C# program to build a custom exception which raises an exception when the argument passed is a
negative number.
5. Write a C# program that processes command line arguments using System.Environment type.
6. What is the output printed by the following and why?
Struct Point {
Public int x, y;
Public Point (int x, int y)
{ this.x = x; this.y = y; }
}
Point p = new Point(10,10);
Object obj = p;
Console.WriteLine(p.x = {0}, p.x);
Console.WriteLine(obj.x = {0}, (Point)obj.x);
7. Design a custom exception for a Stack class by writing Push, Pop, Display methods and add appropriate
exceptions for overflow and underflow. Show the helper class to demonstrate its working.
8. Write a C# application which defines a class shape, with four data members length, breadth, height and
radius, appropriate constructors and methods to calculate the volume of cube, cone and sphere. Also,
write shapeapp, which creates these 3 objects i.e. cube, cone, sphere using appropriate constructors and
calculate their volume with the help of the above class methods.
9. Write a program to define a class vehice and a class engine. Let the vehicle class contain the engine. The
engine should be started at the source and stopped after reaching the destination. Let the speed and the
distance be read. The program should throw an exception when the vehicle tries to travel beyond
destination. Develop the application in C#.
10. Write a C# program to sort an array of instances of student class comprising of id, name, marks using
Array.Sort( ) method. Initially sort based on id, then sort based on marks.

You might also like