Case Studies of Common Csharp Project Report
Case Studies of Common Csharp Project Report
Problem Statement
WebDev Enterprises is a medium sized company that develops Web applications using
J2EE technology for its overseas clients such as BlueSoft Software Solutions and
InterSolutions Private Limited. The management at WebDev recently conducted an
analysis and discovered that it has not been able to use the code of its existing
applications developed in J2EE when developing new J2EE applications. As a result, the
deadlines for the new projects were not being met causing financial loss to WebDev
Enterprises. Because of not being able to meet deadlines, WebDev Enterprises was losing
its clients. In addition, the management of WebDev Enterprises found that it was a
complex task to develop applications in J2EE. How can the management of WebDev
solve the problem?
Solution
In order to be able to reuse the code of existing applications, WebDev must start creating
Web based applications using C# and ASP.NET. C# provides features such as
inheritance and interface that allow reusability of code. This means that code written
for a specific application in C# can be easily used for another C# application.
Inheritance feature of C# allows a class to inherit properties, which contain data and
methods of another class. For example, if you create a class A and define certain
properties such as name and address in it, and a display method to display the values
contained in the properties, then you can use the properties and methods of A class in
another class B.
With the use of C#, programmers working at WebDev Enterprises could develop
applications efficiently and in less time.
C# programming language is supported by Microsoft Visual Studio 2005, which is a
rapid development tool for developing Windows based and Web based applications.
The support for .NET Framework in C# allows you to create interactive user
interfaces for applications in less time. The .NET Framework provides the Control
class that helps use controls, their properties and methods to develop interactive user
interfaces for an application in less time.
Because of all these reasons, which include C# support in Microsoft Visual Studio 2005
and inheritance, the programmers working in WebDev were able to meet the
deadlines for the new projects and satisfy the requirements of the overseas clients.
Thus, with the use of C# and ASP.NET, WebDev has been able to solve its problem and
rapidly develop applications for its overseas clients.
Problem Statement
Solution
After much research, the management of AUPart Enterprise comes to the conclusion that
an application created in a high level programming language such as C# is needed to
automate the task of maintaining the records of manufactured parts. Quick Soft
Solutions Private Limited, which is a software development company, is contacted
by AUPart Enterprise to develop the application for automating the task of
maintaining the records of manufactured parts. The team of programmers at Quick
Soft Solutions Private Limited first conducted an interview with the staff of AUPart
Enterprise to find out their requirements. After requirement analysis, it was decided
by the programmers at Quick Soft Solutions Private Limited that C# features such as
constructors and variables must be used in the application for automating the task of
keeping records of manufactured parts:
using System;
using System.Collections;
class Inventory {
string partName;
double partPrice;
int priceQty;
}
}
In C#, constructors help initialise the objects of a class and variables are used to store
data related to an object. The name of the constructor in C# must be same as the name of
the class.
Problem Statement
Solution
To satisfy the overseas client, Martin should use an object oriented language such as C#
to create the application for converting a number into binary format. C# provides bitwise
operators that can be easily used in a C# application to perform manipulation on binary
data. After much research, Martin develops the following application in C# for
automating the task of converting a number into binary format:
using System;
class Convert {
public int nobits;
public Convert(int n) {
nobits = n;
}
int spaceVal = 0;
for(; mask != 0; mask >>= 1)
{
if((num & mask) != 0)
Console.Write("1");
else
Console.Write("0");
spaceVal++;
if((spaceVal % 8) == 0)
{
Console.Write(" ");
spaceVal = 0;
}
}
Console.WriteLine();
}
}
}
}
The bitwise operators can be easily used in a C# application to shift the bits from left to
right and vice versa. Manually performing the task of bit manipulation is time
consuming and error prone.
Problem Statement
St Peters School is a convent school that provides education from K.G class to 12 th class.
Quarterly, half yearly and final exams are conducted every year for students of all classes
in St Peters School. The class teacher of each class has to prepare a student report for
every student after a particular exam has been conducted. Recently, it has been found by
the principal of St Peters School that a lot of time is being taken by the class teacher in
preparing the student reports. The principal has also found out that the efficiency of the
teachers have decreased because they have been manually performing the task of
preparing the student reports for each student. St Peters have 600 students studying in its
different classes. Preparing student report for at least 30 students per class has become a
tedious task for the class teacher of a specific class. How can the principal of St Peters
School solve the problem of the teachers?
Solution
After holding meetings with senior teachers of the school, the principal of St Peters
School has come to the conclusion that the task of calculating total marks for
preparing a student report must be automated through a software application running
on a computer system. After coming to this conclusion, the principal of St Peters
School asks Nandita, who is teaching computer science to students of higher classes
such as 9th , 10th, 11th and 12th to create the application for automating the task of
calculating total marks that is performed by class teachers while preparing student
report. For this, Nandita first conducts an interview with the class teachers of
different classes to understand their requirements. After the analysis of the
requirements, Nandita decides to use decision making and looping concept of C# in
an application to automate the task of calculating the total marks for each student of
a class. Decision making and looping allows a programmer to decide the flow of
control for a program or application. Nandita creates the following application for
automating the task of calculating total marks:
using System;
class StudentMarks
{
static void Main(string[] args)
{
int[] marks = new int[5];
int totalMarks = 0;
Console.WriteLine("==Student Information==\n");
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("Your total marks are: {0}", totalMarks);
val=(double)totalMarks / 500;
percentage = (double) val*100;
Console.WriteLine("Your percentage is: {0}%", percentage);
Console.ReadLine();
}
In looping, a set of program staements are executed based on a condition. The program
statements are executed until a specific condition is true. When the condition becomes
false the exeuction of the program statements is terminated.
Problem Statement
Solution
In order to make the process of maintaining student records easy and efficient, B.G
International School contacts SoftDev software development organisation to create an
application, which will help in the task of entering the student records. SoftDev assigns
the task of creating the application for B.G International School to Siddarth, who is a
senior programmer in the organisation. Siddarth decides to use the C# programming
language for creating the application to enter student records. C# provides the ArrayList
class in the System.Collections namespace. This ArrayList class allows you to create an
array list, which can store array objects. The size of the array list is fixed at run time.
Thus the array list created using ArrayList class is a dynamic array list. Because a large
amount of data has to be entered in case of B.G International School, use of array list will
be helpful for Siddarth.
After understanding the requirements of B.G International School, Siddarth develops the
following C# application
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
namespace AddStudentDetails
{
class StudentDetails
{
arrlist.Add(studname1);
arrlist.Add(classname1);
arrlist.Add(rollno1);
arrlist.Add(studname2);
arrlist.Add(classname2);
arrlist.Add(rollno2);
arrlist.Add(studname3);
arrlist.Add(classname3);
arrlist.Add(rollno3);
Console.WriteLine("\n");
Console.WriteLine("To remove 2nd student details press y or
to interchange student details1 with student details3 press n.");
getresult = Console.ReadLine();
if (getresult == "y")
{
Console.WriteLine("Removing 2nd Student details");
Console.WriteLine(" ");
arrlist.Remove(studname2);
arrlist.Remove(classname2);
Visit researchgate profile : https://www.researchgate.net/profile/Kamal-Acharya-15/publications
Visit google scholar profile : https://scholar.google.com/citations?user=9QoTDzIAAAAJ&hl=en
12 | P a g e
arrlist.Remove(rollno2);
Console.WriteLine("Current Capcity of the arraylist is
now =" + arrlist.Capacity);
Console.WriteLine("Arraylist is having elements=" +
arrlist.Count);
Console.Write("The elements of Arraylist are now:-");
for (int m = 0; m < arrlist.Count; m++)
{
Console.Write(arrlist[m] + " ");
}
Console.WriteLine("\n");
}
else
{
Console.WriteLine("\n");
Console.WriteLine("Changing elements");
Console.WriteLine(" ");
arrlist[0] = studname3.ToString();
arrlist[1] = classname3;
arrlist[2] = rollno3;
arrlist[6] = studname1;
arrlist[7] = classname1;
arrlist[8] = rollno1;
}
}
}
}
With the use of C# application created by Siddarth, the administrative staff of B.G
International will be able to save time in entering the details such as name and class of
students studying in different classes.
Problem Statement
Solution
CompTech requests one of the programmer, Harsh, who has been working for past two
years in the software development department, to create an application, which will enable
the H.R department to automate the task of entering employee data. In order to
judiciously utilise memory space, Harsh decides to use structure feature of C#. A
structure is a value type that allows you to organise related data of different data types.
After much research, Harsh creates the following C# application:
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureExample
{
public struct Employee
{
private string emp_details;
}
}
class ShowEmployeeDetails
{
static void Main(string[] args)
{
string input = "";
EmployeeDetails emp1 = new EmployeeDetails();
emp1.ShowAllDetails();
Console.WriteLine();
}
}
}
The use of structure in a C# application allows you to manage the memory of a computer
efficiently as all related data is organised in a structure. It also increases the performance
of a C# application.
Problem Statement
Solution
To automate the task of calculating area of different shapes such as circle and rectangle,
ArchBuild contacts ABC SoftDev Private Limited, which is a software development
organisation. ArchBuild asks ABC SoftDev to create an application, which will allow the
architects working in ArchBuild to obtain the area of a shape. ABC SoftDev first
performs requirement analysis to understand the requirements of the architects. After
requirement analysis, it starts developing an application using the inheritance feature of
C# programming language. Inheritance feature allows a class in C# to inherit the
properties and methods defined in another class besides having its own properties and
methods. Inheritance allows programmers to reuse the code of one application in another
application. The ABC SoftDev creates the following application for ArchBuild to
automate the task of calculating area for different shapes:
using System;
using System.Collections.Generic;
using System.Text;
namespace CaseStudy13
{
public abstract class Dimension_Shape
{
class AreaandColor
Visit researchgate profile : https://www.researchgate.net/profile/Kamal-Acharya-15/publications
Visit google scholar profile : https://scholar.google.com/citations?user=9QoTDzIAAAAJ&hl=en
18 | P a g e
{
static void Main(string[] args)
{
Console.WriteLine("This is an example where all the
properties of different classes\nlike Circle,Square can be defined in
another class and can be inherited \nfrom it when required without
populating the classes with excess codes.");
Console.WriteLine(" ----------------------------- ");
Dimension_Shape myCircle = new ShapeCircle("Maroon", 6);
Dimension_Shape myRectangle = new ShapeRectangle("Blue",
12, 9);
Dimension_Shape mySquare = new ShapeSquare("Gray", 15);
System.Console.WriteLine("The Circle is of " +
myCircle.getColor()
+ " color and its area is " +
myCircle.getAreaof_Shape() + ".");
Console.WriteLine(" ------------------------------- ");
System.Console.WriteLine("The Rectangle is of " +
myRectangle.getColor()
+ " color and its area is " +
myRectangle.getAreaof_Shape() + ".");
Console.WriteLine(" ------------------------------- ");
System.Console.WriteLine("The square is of " +
mySquare.getColor()
+ " color and its area is " + mySquare.getAreaof_Shape()
+ ".");
Console.WriteLine(" ------------------------------- ");
}
}
}
The use of inheritance in the application for calculating the area helps programmers avoid
defining excess code in one class. The properties and methods defined in one class can be
easily used in another class because of inheritance
Problem Statement
UInfo Private Limited is involved in the development of new aircrafts for companies like
AeroFly and FlyHigh. When developing the designs for the new aircrafts the designing
staff of UInfo has to do a number of complex calculations. Manually performing these
complex calculations has become tedious task for the designing staff of UInfo. How can
UInfo automate the task of performing complex calculations?
Solution
The management of UInfo after much discussion came to the conclusion that an
application must be developed to automate the task of performing complex
calculations. For this purpose, it contacts a software development company called
ABC Software Solutions Private Limited. This software development company first
performs a requirement analysis to understand the requirements of UInfo. It then
decides that operator overloading feature of C# should be used in a C# application to
overload operators such as + and _ so that different functions can be performed using
the same operator. After 10 days, the ABC Software Solutions Private Limited
comes up with the following C# application, which helps perform mathematical
operations such as adding and multiplying two numbers:
using System;
using System.Collections.Generic;
using System.Text;
namespace OperatorOverloading
{
class StoreValue
{
private int num1;
private int num2;
public StoreValue()
{
}
public StoreValue(int m, int n)
{
num1 = m+m;
num2 = n+n;
}
public void DisplayWindow()
{
Console.WriteLine("The sum of numbers is {0} {1}", num1,
num2);
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Operator Overloading with Inheritance.");
StoreValue Obj1 = new StoreValue(119,280);
Obj1.DisplayWindow();
InheritValue Obj2 = new InheritValue(355,455);
Obj2.DisplayWindow();
InheritMoreValue Obj3 = new InheritMoreValue(150,250);
Obj3.DisplayWindow();
}
}
}
Problem Statement
Modern Engineering Collage provides courses for streams such as mechanical, electrical,
electronics and civil. When a student takes admission in the Modern Engineering Collage
and comes to the administrative staff to pay the fees, the staff has to manually fill a form
specifying details such as name, address, course and fees. A large amount of time is
consumed in the filling of the form. In addition, the efficiency of the administrative staff
also decreases as a lot of time is spent in filling of the form. The students who are taking
admission in the Modern Engineering Collage have to wait for long time in a queue for
paying their fees. How can Modern Engineering Collage solve this problem of the
students and the administrative staff?
Solution
The principal of Modern Engineering Collage along with some of the important
management staff conducts a meeting and tries to find the solution to the problem, which
is being faced by the students taking admission in the collage and the administrative staff.
By the end of the meeting, the principal and the management staff come to the conclusion
that an application must be developed for automating the task of entering student
information such as name and address. The principal calls the Head of the Electronics
department after a few days and asks the Head to develop the application. The Head of
the Electronics department first conducts a requirement analysis through interviews with
the administrative staff of the collage. After the analysis, the Head of Electronics
Department comes to the conclusion that methods such as ReadLine() and WriteLine()
available in C# must be used in a C# application for obtaining details such as name and
address and displaying a message to confirm the admission of the student. The methods
such as ReadLine() and WriteLine() help in receiving inputs from users and displaying
output. The following C# application is developed by the Head of the Electronics
department:
using System;
using System.Collections.Generic;
using System.Text;
namespace StudentAdmissionSystem
{
public enum Degree
{
Mechanical = 1,
Electrical,
Electronics,
Aeronautics,
Civil
}
class Select
{
public Select()
{
degree = Degree.Civil;
}
public Select(Degree degree)
{
degree = Degree.Civil;
}
class GetDetails
{
Select degree;
string name,address,telephone,course,fees;
public GetDetails()
{
degree = new Select();
}
switch (choice)
{
case 1:
degree.degree = Degree.Mechanical;
break;
case 2:
degree.degree = Degree.Electrical;
break;
case 3:
degree.degree = Degree.Electronics;
break;
case 4:
degree.degree = Degree.Aeronautics;
break;
default:
degree.degree = Degree.Civil;
break;
Visit researchgate profile : https://www.researchgate.net/profile/Kamal-Acharya-15/publications
Visit google scholar profile : https://scholar.google.com/citations?user=9QoTDzIAAAAJ&hl=en
24 | P a g e
}
}
class StudentMenu
{
static void Main(string[] args)
{
GetDetails gd = new GetDetails();
gd.GetAdmission();
Console.WriteLine();
gd.GetStudentDetails();
Console.WriteLine();
Console.WriteLine("Thank You " + gd.name + " for
getting Admission in " + gd.course+ " course.");
}
}
}
}
In C#, methods such as Read() and Write() allow programmers to perform input and
output operations. This means that these methods can be used to receive inputs such as
text and numbers from a user in a specific format and display the output in a particular
format.
Problem Statement
Solution
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
namespace Threading
{
class ThreadedApplications
{
static void Main(string[] args)
{
ApplicationCounter acObj = new ApplicationCounter();
ThreadStart execute = new
ThreadStart(acObj.application_stopstart);
ThirdPartyApplications acObj2 = new
ThirdPartyApplications();
ThreadStart execute2 = new
ThreadStart(acObj2.thirdapplication_stopstart);
Thread applications = new Thread(execute);
Console.WriteLine("Starting the Primary Application.");
Thread applications2 = new Thread(execute2);
//starting the primary application
applications.Start();
applications2.Start();
Thread.Sleep(1000);
}
Console.WriteLine("Primary Application ended");
}
}
Thread.Sleep(500);
}
Console.WriteLine("Secondary Application ended");
}
}
Thread.Sleep(2000);
}
Console.WriteLine("Third Party Applications ended");
}
}
}
In C#, multithreading helps in optimising the resources related to a specific application. It
also helps in faster execution of an application. Multithreading can be used in C# to
create different threads for performing operations such as checking the user input
and performing background tasks.
References