Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
15 views76 pages

Dot Net - Lab Vi

The document outlines practical work for a Bachelor of Science in Information Technology program at Nirmala College for Women, focusing on .NET programming. It includes various exercises such as formatting dates, checking voting eligibility, creating a phonebook application, form navigation, implementing the Tower of Hanoi game, and building a calculator. Each exercise provides an aim, algorithm, source code, and results indicating successful execution.

Uploaded by

BCA NIRMALA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views76 pages

Dot Net - Lab Vi

The document outlines practical work for a Bachelor of Science in Information Technology program at Nirmala College for Women, focusing on .NET programming. It includes various exercises such as formatting dates, checking voting eligibility, creating a phonebook application, form navigation, implementing the Tower of Hanoi game, and building a calculator. Each exercise provides an aim, algorithm, source code, and results indicating successful execution.

Uploaded by

BCA NIRMALA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 76

NIRMALA COLLEGE FOR WOMEN

(AUTONOMOUS)

COIMBATORE-18

BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY

SEMESTER VI

CORE LAB VI: DOT NET PROGRAMMING


NIRMALA COLLEGE FOR WOMEN

(AUTONOMOUS)

COIMBATORE-18

BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY

SEMESTER VI

Certified Bonafide record of practical work done during the year 2024-2025

REGISTER NO:

Submitted for the Practical Examination

CORE LAB VI: DOT NET PROGRAMMING

Held on at Nirmala College for Women (Autonomous),

Red Fields, Coimbatore-641 018.

Staff In-Charge Head of the Department

Internal Examiner External Examiner


INDEX

SNO DATE PROGRAM NAME PAGE NO SIGNATURE

FORMATING DATE
1.

2. VOTING ELIGIBILITY

PHONEBOOK
3.

4. FORM NAVIGATION

5. TOWER OF HANOI

CALCULATOR
6.

STUDENT MARKSHEET
7.

8. ELECTRICITY BILL

9. COLLEGE PORTAL

JOB PORTAL
10.
EX.NO:01

FORMATTING DATE
ATE FORMATE
DATE:

AIM:

To write a C# program to display the date in various formats.

ALGORITHM:

STEP 1: Start the process.

STEP 2: Open Visual Studio 2012 and create New project.

STEP 2: Import necessary namespaces.

STEP 3: Define main method.

STEP 4: Read the current Date and Time value

STEP 5: Format and Print various date and time formats using ToString() method:

STEP 6: Run the program and Stop the Process.


SOURCE CODE:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DATE_FORMAT
{
class Program
{
static void Main(string[] args)
{
DateTime D = new DateTime();
D = DateTime.Now;
Console.WriteLine(" Date Formate");
Console.WriteLine(" ******* *********");
Console.WriteLine(Date.ToString("MM/dd/yyyy"));
Console.WriteLine(Date.ToString("dddd, dd MMMM yyyy"));
Console.WriteLine(Date.ToString("dddd, dd MMMM yyyy"));
Console.WriteLine(Date.ToString("dddd, dd MMMM yyyy"));
Console.WriteLine(Date.ToString("dddd, dd MMMM yyyy"));
Console.WriteLine(Date.ToString("dddd, dd MMMM yyyy"));
Console.WriteLine(Date.ToString("dddd, dd MMMM yyyy HH:mm:ss"));
Console.WriteLine(Date.ToString("MM/dd/yyyy HH:mm"));
Console.WriteLine(Date.ToString("MM/dd/yyyy hh:mm tt"));
Console.WriteLine(Date.ToString("MM/dd/yyyy H:mm"));
Console.WriteLine(Date.ToString("MM/dd/yyyy h:mm tt"));
Console.WriteLine(Date.ToString("MM/dd/yyyy HH:mm:ss"));
Console.WriteLine(Date.ToString("MMMM dd"));
Console.ReadLine();
}
}
}
OUTPUT:
RESULT:
Thus, the program to display the date in various formats has been successfully
executed.
EX.NO:02

VOTE ELIGIBILITY

DATE:

AIM:

To Write a C# Program to determine a Candidates Age is Eligible for Casting the Vote
or Not.

ALGORITHM:

STEP 1: Start the Process. Open Visual Studio 2012 and create new project in
Console Application

STEP 2: Import the necessary namespaces (System) for input and output.

STEP 3: Defines a class and declare a variable age to store the users age.

STEP 4: Prompt the user to enter their age using Console.Write("Enter Your Age:").

STEP 5: Read the user's input as a string using Console.ReadLine() and parses it into
an integer using int.Parse().

STEP 6: Check if the entered age is greater than or equal to 18 using if statement.

STEP 7: If the age is greater than or equal to 18, print " !!! You are Eligible for
voting...".

STEP 8: If the age is less than 18, print "Sorry!!! You are Not Eligible for voting...".

STEP 9: Run the Program and Stop the Process.


SOURCE CODE:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VOTING_ELIGIBILITY
{
class Program
{
static void Main(string[] args)
{
int age;
Console.Write("Enter Your Age:");

age= int.Parse(Console.ReadLine());

if (age >= 18)


{

Console.WriteLine("!!! You are Eligible for voting...");


Console.ReadLine();
}
else
{
Console.Write("Sorry!!! You are Not Eligible for voting...");
Console.ReadLine();
}

}
OUTPUT:
RESULT:
Thus, the program to determine a Candidates Age is Eligible for Casting the Vote
or Not has been successfully executed.
EX.NO:02

VOTE ELIGIBILITY

DATE:

AIM:
To Write a C# Program to determine a Candidates Age is Eligible for Casting the Vote or
Not in Window Application.

ALGORITHM:

STEP 1: Start the process. Open Visual Studio 2012. Create a new Windows Forms Application.

STEP 2: Add controls like Label, TextBox for age input and Button to trigger the
eligibility check.

STEP 3: Add a TextBox named as txtAge where users will enter their age.

STEP 4: Add a Button named btnCheck to check eligibility.

STEP 5: Retrieve the input age from the user.

STEP 6: If the age is 18 or greater, the person is eligible to vote.


Displays the eligibility result on the Message Box.

STEP 7: Run the Program and Stop the Program.


SOURCE CODE:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace VOTING
{
public partial class Form1 : Form
{
int age;
public Form1()
{
InitializeComponent();
}

private void btncheck_Click(object sender, EventArgs e)


{
age = Convert.ToInt32(txtage.Text);

if (age >= 18)


{

MessageBox.Show("eligible to vote");
}

else
{ MessageBox.Show("not eligible”);

}
}
}
OUTPUT:
RESULT:
Thus, the program to determine a Candidates Age is Eligible for Casting the Vote or
Not has been successfully executed.
EX.NO:03

PHONEBOOK

DATE:

AIM:
To create a C# program to implement the PhoneBook.

ALGORITHM:

STEP 1: Start the process. Open Visual Studio 2012 and create New windows form applicaton.

STEP 2: Import necessary namespaces.

STEP 3: Add a DataGrid View control named dataGridView1, two Textbox controls
named textBox1 and textBox2, and three Button controls named btnsave,
btndel, and btnload to the form.

STEP 4: Declare a Data Table variable named phonebook to store the phonebook data
and a boolean variable named editing to keep track of whether the user is
editing an existing entry.

STEP 5: Implement the btnsave_Click event handler to update the Name and Phone No
values of the current row in the phonebook Data Table.

STEP 6: Implement the btndel Click event handler to delete the current row from the
phonebook Data Table.

STEP 7: Implement the btnload Click event handler to the Name value of the current
row in the phonebook Data Table.

STEP 8: Add columns "NAME" and "PHONE NO" to the phonebook Data Table and
set the Data Source property of the dataGridView1 control to the phonebook
Data Table.

STEP 9: Run the program and stop the process.


SOURCE CODE:

using System;
usingSystem.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication13
{
public partial class Form1 : Form
{
DataTable phonebook = new DataTable();
bool editing = false;
public Form1()
{
InitializeComponent();
}

private void btnsave_Click(object sender, EventArgs e)


{
if (editing)
{
phonebook.Rows[dataGridView1.CurrentCell.RowIndex]["Name"] = textBox1.Text;
phonebook.Rows[dataGridView1.CurrentCell.RowIndex]["Phone No"] = textBox2.Text;
}
else
{
phonebook.Rows.Add(textBox1.Text, textBox2.Text);
}

textBox1.Text="";

textBox2.Text="";

editing = false;
}
private void btndelete_Click(object sender, EventArgs e)
{
try
{
phonebook.Rows[dataGridView1.CurrentCell.RowIndex].Delete();
}
Catch(Expection e)
{
MessageBox.Show("Not a valid row");
}
}

private void btnload_Click(object sender, EventArgs e)


{

textBox1.Text=phonebook.Rows[dataGridView1.CurrentCell.RowIndex].ItemArray[0].ToString();
textBox2.Text=phonebook.Rows[dataGridView1.CurrentCell.RowIndex].ItemArray[1].ToString();
}

private void Form1_Load(object sender, EventArgs e)


{
phonebook.Columns.Add("NAME");
phonebook.Columns.Add("PHONE NO");
dataGridView1.DataSource = phonebook;
}

}
OUTPUT:
RESULT:
Thus, the program to implement the Phonebook. has been successfully executed.
EX.NO:04

FORM NAVIGATION

DATE:

AIM:
To write a C# application where users can enter their name and address in two text
boxes. Upon clicking a button, the Application will navigate to a different page and display
the name and address in different colors.

ALGORITHM:

STEP 1: Start tha process. Open Visual Studio 2012 on your system.

STEP 2: Creating a New Windows Forms Application. Click on File - > New - >
Project.

STEP 3: Name your project and click OK.

STEP 4: Design Form1 and change the form name. Add two TextBox controls
(txtname and txtaddress). Add a Button control (button1 labeled Submit).

STEP 5: Double-click the Submit button to create the btn_Submit event handler.
Add the code in Form1.cs.

STEP 6: Add a new form to your project: Right-click on the project in the Solution
Explorer. Click Add -> Windows Form.

STEP 7: Name it Form2.cs.

STEP 8: Open Form2 in the designer view. From the toolbox, drag and drop two
Label controls onto the form:.

STEP 9 : Run the program and Stop the Process.


SOURCE CODE:

FORM1:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace REGISTRATION
{
public partial class REGISTRATION : Form
{
public static string name = "";

public static string address = "";

public REGISTRATION()
{
InitializeComponent();
}

private void btnsubmit_Click(object sender, EventArgs e)


{

name = txtname.Text;
address = txtaddress.Text;
display f2 = new display();
f2.Show();
}
}
}
FORM2

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace REGISTRATION
{
public partial class display : Form
{
public display()
{
InitializeComponent();
}
private void display_Load(object sender, EventArgs e)
{
label1.Text = REGISTRATION.name;

label2.Text = REGISTRATION.address;
}
}
}
OUTPUT:

FORM1: REGISTRATION

FORM2: DISPLAY
RESULT:
Thus, the program to display the Form Navigation has been successfully executed.
EX.NO:05

TOWER OF HANOI

DATE:

AIM:

To write a C# Program to demonstrate Tower of Hanoi Game.

ALGORITHM:

STEP 1: Start the process. Open Visual Studio 2012 and create New Project.

STEP 2: Define Tower of Hanoi class with num discs field and constructors to
initialize it.

STEP 3: Implement num discs property with get and set accessors.

STEP 4: Define move tower method to solve the Tower of Hanoi problem recursively.

STEP 5: Inside move tower method, if n > 0, recursively move n-1 disks from the
source peg to the auxiliary peg, then move the nth disk from the source
peg to the destination peg, and finally recursively move n-1 disks from
the auxiliary peg to the destination peg.

STEP 6: Define Towers of Hanoi Application class with the Main method.

STEP 7: Instantiate Tower of Hanoi object T.

STEP 8: Prompt the user to enter the number of discs.

STEP 9: Read the input from the console and assign it to T.numdiscs.

STEP 10: Call to move tower method with parameters T.numdiscs, 1, 3, and 2 to
solve the Tower of Hanoi problem.

STEP 12: Run the Program. Stop the process.


SOURCE CODE:

using System;
class TowerOfHanoi
{
int m_numdiscs;
public TowerOfHanoi()
{
numdiscs = 0;
}
public TowerOfHanoi(int newval)
{
numdiscs = newval;
}
public int numdiscs()
{
get
{
return m_numdiscs;
}
set
{
if (value > 0)

m_numdiscs = value;
}
}
public void movetower(int n, int from, int to, int other)
{
if (n > 0)
{
movetower(n - 1, from, other, to);
Console.WriteLine("Move disk {0} from tower {1} to tower{2}"n,from, to);
movetower(n - 1, other, to, from);
}
}
}
class TowersOfHanoiApp
{

public static int Main()


{
TowerOfHanoi T = new TowerOfHanoi();

string cnumdiscs;
Console.Write("Enter the number of discs: ");
cnumdiscs = Console.ReadLine();
T.numdiscs =Convert.ToInt32(cnumdiscs);
T.movetower(T.numdiscs, 1, 3, 2);
Console.ReadLine();
return 0;
}
OUTPUT
RESULT:
Thus, the program to demonstrate Tower of Hanoi Game has been successfully
executed.
EX.NO:06

CALCULATOR

DATE:

AIM:

To create a calculator using button to enter different input values and display result
using button to perform arithmetic operation.

ALGORITHM:

STEP 1: Start the process. Open Visual Studio 2012 and create New windows form application.

STEP 2: Import necessary namespaces.

STEP 3: Create a Windows Form application with a text box (t1) to display input and
results, and several buttons (b1 to b10, clear, add, sub, mul, div, and
equaltoo) to input numbers and perform operations.

STEP 4: The btnclear event handler clears the content of the text box (t1) when the
“clear" button is clicked.

STEP 5: The btnadd, btnsub,btnmulti, and btndiv event handlers are triggered
when the corresponding operation buttons are clicked.

STEP 6: The btnequal event handler calculates the result based on the operation
selected (msg) and displays it in the text box.

STEP 7: Run the program and stop the process.


SOURCE CODE:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CALCULATOR
{
public partial class Form1 : Form
{
int a = 0; int b, c;
string msg;
public Form1()
{
InitializeComponent();
}
private void b1_Click(object sender, EventArgs e)
{
t1.Text = t1.Text + b1.Text;
}

private void b2_Click(object sender, EventArgs e)


{
t1.Text = t1.Text + b2.Text;
}

private void b3_Click(object sender, EventArgs e)


{
t1.Text = t1.Text + b3.Text;
}

private void b4_Click(object sender, EventArgs e)


{
t1.Text = t1.Text + b4.Text;
}

private void b5_Click(object sender, EventArgs e)


{
t1.Text = t1.Text + b5.Text;
}

private void b6_Click(object sender, EventArgs e)


{
t1.Text = t1.Text + b6.Text;
}

private void b7_Click(object sender, EventArgs e)


{
t1.Text = t1.Text + b7.Text;
}

private void b8_Click(object sender, EventArgs e)


{
t1.Text = t1.Text + b8.Text;
}

private void b9_Click(object sender, EventArgs e)


{
t1.Text = t1.Text + b9.Text;
}

private void b0_Click(object sender, EventArgs e)


{
t1.Text = t1.Text + b0.Text;
}

private void btnclear_Click(object sender, EventArgs e)


{
t1.Text = "";
}

private void btndiv_Click(object sender, EventArgs e)


{
a = Convert.ToInt32(t1.Text);
t1.Text = "";
msg = "/";
}
private void btnmulti_Click(object sender, EventArgs e)
{
a = Convert.ToInt32(t1.Text);
t1.Text = "";
msg = "*";
}

private void btnadd_Click(object sender, EventArgs e)


{
a = Convert.ToInt32(t1.Text);
t1.Text = "";
msg = "+";
}
private void btnsub_Click(object sender, EventArgs e)
{
a = Convert.ToInt32(t1.Text);
t1.Text = "";
msg = "-";
}

private void btnequal_Click(object sender, EventArgs e)


{
if (msg == "+")
{
b = Convert.ToInt32(t1.Text);
c = a + b;
}
if (msg == "-")
{
b = Convert.ToInt32(t1.Text);
c = a - b;
}
if (msg == "*")
{
b = Convert.ToInt32(t1.Text);
c = a * b;
}
if (msg == "/")
{
b = Convert.ToInt32(t1.Text);
c = a / b;
}
t1.Text = c.ToString();
}
}
}
OUTPUT:
RESULT:
Thus, the program to perform arithmetic operation using Calculator has been
successfully executed.
EX.NO:07

STUDENT MARKSHEET

DATE:

AIM:
To Create a program to Calculate a student's total marks, percentage, and grade
base on their performance in four subjects, facilitating an evaluation of their
academic standing.

ALGORITHM:

STEP 1: Start the process. Open Visual Studio 2012 and create a New Project in Console
Application.

STEP 2: Initialize variables for register number, student name, marks of subjects, total
marks, and percentage.

STEP 3: Prompt the user to enter the student's name and marks for each subject.

STEP 4: The percentage is calculated based on the total marks (out of 400) and
multiplied by 100 to convert it to a percentage.

STEP 5: Assign A+ for >= 90%, A for >= 80%, and so on.

STEP 6: The program displays a simple mark sheet with the student's name, subject-
wise marks, total marks, percentage, and grade.

STEP 7: Run the program and Stop the process.


SOURCE CODE:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MARKSHEET
{
class Program
{
static void Main(string[] args)
{
int m1, m2, m3, m4, t;
float p;
string reg, n;
Console.WriteLine(" STUDENT MARKSHEET");

Console.WriteLine(" ******* *********");


Console.WriteLine("Enter Register Number:");
reg = Console.ReadLine();
Console.WriteLine("Enter Student Name:");
n = Console.ReadLine();
Console.WriteLine("Mark of Cloud Computing:");
m1 = int.Parse(Console.ReadLine());
Console.WriteLine("Mark of MachineLearning:");
m2 = int.Parse(Console.ReadLine());

Console.WriteLine("Mark of Food Science:");


m3 = int.Parse(Console.ReadLine());
Console.WriteLine("Mark of Data Science:");

m4 = int.Parse(Console.ReadLine());
t = m1 + m2 + m3 + m4;
p = (float)t / 4.0f;
Console.WriteLine("Total: " + t);
Console.WriteLine("Percentage: " + p);
if (p >= 80)
{
Console.WriteLine("Grade is A+");
}
else if (p >= 60)
{
Console.WriteLine("Grade is A");
}
else if (p >= 50)
{
Console.WriteLine("Grade is B");
}
else if (p >= 35)
{
Console.WriteLine("Grade is C");
}
else
{
Console.WriteLine("Grade is F");
}
Console.ReadLine();
}
}
}
OUTPUT:
RESULT:
Thus, the program to Calculate the student Marksheet has been successfully executed.
EX.NO:07

STUDENT MARKSHEET

DATE:

AIM:

To write a C# Program to generate Marksheet of the Student

ALGORITHM:

STEP 1: Open Visual Studio 2012 and create new windows form application.

STEP 2: Import necessary namespaces.

STEP 3: Initialize variables m1, m2, m3, m4, Total, and Percentage.

STEP 4: Create a form named MARKSHEET.

STEP 5: Add controls like text boxes and buttons for input and output.

STEP 6: Implement an event handler for the button click event


(btncalculate_Click) inside the event handler.

STEP 7: Parse input values from text boxes (txtm1, txtm2, txtm3, txtm4) to
integers (m1, m2, m3, m4).

STEP 8: Calculate the total marks (Total) by adding m1, m2, m3, and m4.

STEP 9: Display the total marks in the txttotal text box.

STEP 10: Calculate the percentage (Percentage) by dividing Total by 4.

STEP 11: Display the percentage in the txtpercentage text box.

STEP 12: Determine the grade based on the percentage.

STEP 13: If Percentage is greater than or equal to 80, assign "A+" to the
txtgrade text box.

STEP 14: Else if Percentage is greater than or equal to 60, assign "A".
STEP 15: Else if Percentage is greater than or equal to 50, assign "B".

STEP 16: Else if Percentage is greater than or equal to 35, assign "C". Or, assign "F".

STEP 17: Run the program and Stop the process.


SOURCE CODE:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace STUDENT_MARKSHEET
{
public partial class MARKSHEET : Form
{
int m1, m2, m3,m4, Total;
float Percentage;
public MARKSHEET()
{
InitializeComponent();
}
private void btncalculate_Click(object sender, EventArgs e)
{
m1 = int.Parse(txtm1.Text);

m2 = int.Parse(txtm2.Text);

m3 = int.Parse(txtm3.Text);

m4 = int.Parse(txtm4.Text);
Total = m1 + m2 + m3 + m4;

txttotal.Text = Total.ToString();

Percentage = Total /4;


txtpercentage.Text = Percentage.ToString();

if (Percentage>=80)
{
txtgrade.Text = "A+";
}
else if(Percentage>=60)
{
txtgrade.Text = "A";
}
else if(Percentage >=50)
{
txtgrade.Text = "B";
}
else if(Percentage >=35)
{
txtgrade.Text = "C";
}
else
{
txtgrade.Text = "F";
}
}
}
}
OUTPUT:
RESULT:
Thus, the program to Calculate the student Marksheet has been successfully executed.
EX.NO:08

ELECTRICITY BILL

DATE:

AIM:

To create a C# program to calculate the electricity bill in Console Application

ALGORITHM:

STEP 1: Start the process. Open Visual Studio 2012 and create New console applicaton.

STEP 2: Import necessary namespaces.

STEP 3: Initialize variables ID, Unit, TotalAmount, and ChargePerUnit to zero.

STEP 4: Read and store the Customer ID (ID) from the user.

STEP 5: Prompt the user to enter the Customer Name.

STEP 6: Read and store the Customer Name (Name) from the user.

STEP 7: Prompt the user to enter the consumed units.

STEP 8: Along with Previous Unit and Current Unit.

STEP 9 : Read and store the consumed units (Unit) from the user.

STEP 10: Check the range of consumed units:

If Unit is between 0 and 199 (inclusive): Set ChargePerUnit to 1.20.

If Unit is between 200 and 399 (inclusive): Set ChargePerUnit to 1.50.

If Unit is between 400 and 599 (inclusive): Set ChargePerUnit to 1.80.

If Unit is 600 or more: Set ChargePerUnit to 2.00.

STEP 11: Calculate TotalAmount as Unit * ChargePerUnit.


STEP 12: Display the calculated amount.

STEP 13: Run the Program and Stop the process.


SOURCE CODE:

using System;

namespace ElectricityBill
{
class Program
{
static void Main(string[] args)
{
int ID, PreviousReading, CurrentReading, Unit;
double TotalAmount = 0, ChargePerUnit = 0;

Console.WriteLine("ELECTRICITY BILL");

Console.Write("Enter Customer ID: ");


ID = int.Parse(Console.ReadLine());
Console.Write("Enter Customer Name: ");
string Name = Console.ReadLine();
Console.Write("Enter Previous Reading:”);
PreviousReading = int.Parse(Console.ReadLine());
Console.Write("Enter Current Reading: ");
CurrentReading = int.Parse(Console.ReadLine());
Unit = CurrentReading - PreviousReading;
Console.WriteLine("\nCustomer ID No: {0}", ID);
Console.WriteLine("Customer Name: {0}", Name);
Console.WriteLine("Units Consumed: {0}", Unit);

if (Unit >= 0 && Unit <= 199)


{
ChargePerUnit = 1.20;
}
else if (Unit >= 200 && Unit <= 399)
{
ChargePerUnit = 1.50;
}

else if (Unit >= 400 && Unit <= 599)


{
ChargePerUnit = 1.80;
}
else if (Unit >= 600)
{
ChargePerUnit = 2.00;
}

TotalAmount = Unit * ChargePerUnit; if

(TotalAmount > 400)


{
TotalAmount += TotalAmount * 0.15;
}

if (TotalAmount < 100)


{
TotalAmount = 100;
}

TotalAmount = Math.Round(TotalAmount, 2);


Console.WriteLine("\nAmount Charged: Rs.{0}", TotalAmount);
Console.ReadLine();
}
OUTPUT:
RESULT:
Thus, the program to Calculate Electricity Bill has been successfully executed.
EX.NO:08

ELECTRICITY BILL

DATE:

AIM:
To create a C# program to calculate the electricity bill in windows Form
Application

ALGORITHM:

STEP 1: Start the process. Open Visual Studio 2012 and create a new windows form
application.
STEP 2: Import necessary namespaces.

STEP 3: Start the Windows Forms application.

STEP 4: Create a form with controls including TextBoxes for entering current and

previous meter readings, and buttons for calculating and displaying the bill.

STEP 5: Create event handlers for button clicks and form load.

STEP 6: In the event handler for the "Calculate" button click (CALCULATE_Click),

Parse the values entered in the current and previous meter reading textboxes

(“TXTCUR“) and “TXTPREV”) as integers.

STEP 7: Calculate and display the consumed units by subtracting the previous reading

from the current reading.

STEP 8: Display the calculated bill amount in a textbox (“TXTAMNT”).

STEP 9: Display the total amount charged.

STEP 10: Run the program and Stop the process.


SOURCE CODE:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication12
{
public partial class Form1 : Form
{
int unit, amnt;

public Form1()
{
Initialize Component();
}

private void btncalculate_Click(object sender, EventArgs e)


{
unit = Convert.ToInt32(txtcur.Text) - Convert.ToInt32(txtprev.Text);

txtunit.Text = unit.ToString();
if (unit >= 500)
{
amnt = unit * 5;

txtamnt.Text = amnt.ToString();
}
else if (unit >= 300 && unit <= 500)
{
amnt = unit * 4;
txtamnt.Text= amnt.ToString();
}
else if (unit >= 200 && unit <= 300)
{
amnt = unit * 2;
txtamnt.Text = amnt.ToString();
}
else
{
amnt = unit * 1;
txtamnt.Text = amnt.ToString();
}
}
private void Form1_Load(object sender, EventArgs e)
{
this.WindowState=FormWindowState.Maximized;
}
}
}
OUTPUT:
RESULT:
Thus, the program to Calculate Electricity Bill has been successfully executed.
EX.NO:09

COLLEGE PORTAL

DATE:

AIM:
To create a C# program for College Portal.

ALGORITHM:

STEP 1: Start the process. Open Visual Studio 2012 and create a new windows form
application.

STEP 2: Import necessary namespaces.

STEP 3: Create two forms.

STEP 4: Design Registration form with Name, Parent name, Date of Birth and
Course.
STEP 5: Design Form1 with a link label as Register.

STEP 6: Create Database name as College and Table name as College with the
following fields Name, Parentname, DOB, and Course.
STEP 7: Create a new connection by right clicking on Server Explorer-> Add Connection.

STEP 8: Retrieve the connection string for the SQL Server database.

STEP 9: Establish connection to the database using the connection string.

STEP 10: Define a SQL command to insert user registration data into the `college` table.

STEP 11: Add parameters to the SQL command for user input data obtained from
various text boxes and combo boxes.
STEP 12: Opens the database connection.

STEP 13: Execute the SQL command to insert the user registration data.

STEP 14: Display a message box indicating successful registration.

STEP 15: Run the program and Stop the process.


SOURCE CODE:

FORM1:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication7
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)


{

Form2 f2 = new Form2();


f2.Show();

}
}
FORM2:

using System;
System.Collections.Generic;
usingSystem.ComponentModl;
using System.Data;
usingSystem.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication7
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}

private void btnsubmit_Click(object sender, EventArgs e)


{

string constring = "Data Source=fatima\\SQLEXPRESS;Initial Catalog=college;Integrated Security=True";


using (SqlConnection con = new SqlConnection(constring))
{
using (SqlCommand cmd = new SqlCommand("INSERT INTO college
VALUES(@name,@parentname,@dob,@course)", con))
{
cmd.Parameters.AddWithValue("@name", txtname.Text);
cmd.Parameters.AddWithValue("@parentname", txtpn.Text);
cmd.Parameters.AddWithValue("@dob", txtdob.Text);
cmd.Parameters.AddWithValue("@course", cbocourse.SelectedItem);
con.Open();
cmd.ExecuteNonQuery();
MessageBox.Show("successfully registred");
}
}
}
OUTPUT:

FORM1: COLLEGE PORTAL


FORM2: REGISTRATION:

DATABASE TABLE:
RESULT:
Thus, the program College Portal has been successfully executed.
EX:NO:10
EX.NO:10

DATE: JOB
JOB PORTAL
PORTAL

DATE:

AIM:
To create a C# program for job Portal.

ALGORITHM:

STEP 1: Start the process. Open Visual Studio 2008 and create a new windows form
application

STEP 2: Import necessary namespaces.

STEP 3: Create two forms Home and Registration.

STEP 4: Design Registration form First name, last name, DOB, gender, address, phone
no, e- mail, qualification, experience, company name, branch, position, salary and
Place a Button and named as btn_register.

STEP 5: Design Home page with a link label as Register.

STEP 6: Create Database name as jobportal and Table name as job with the following
fields First name, last name, DOB, gender, address, phone no, e-mail,
qualification, experience, company name, branch, position, salary.

STEP 7: Create a New connection by right clicking on Server Explorer-> Add Connection.

STEP 8: Retrieve the connection string for the SQL Server database.

STEP 9: Establish connection to the database using the connection string.


STEP 10: Define a SQL command to insert user registration data into the `jobportal` table.

STEP 11: Add parameters to the SQL command for user input data obtained from

various text boxes and combo boxes.

STEP 12: Open the database connection.

STEP 13: Execute the SQL command to insert the user registration data.

STEP 14: Display a message box indicating successful registration.

STEP 15: Run the program and Stop the process


SOURCE CODE:

FORM 1:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace jobportal
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void btnbutton_Click(object sender, EventArgs e)


{
string conString = " Data Source=fatima\\SQLEXPRESS
;Initial Catalog=job;Integrated Security=True";
using (SqlConnection con = new SqlConnection(conString))
{
using (SqlCommand cmd = new SqlCommand("INSERT INTO JOBPORT
VALUES(@Firstname,@Lastname,@Email,@Phoneno,@DoB,@Gender,@Address,
@Qualification,@Experience,@Companyname,@Branch,@Position,@Expsalary)", con))
{
cmd.Parameters.AddWithValue("@Firstname",txtname.Text);
cmd.Parameters.AddWithValue("@Lastname", txtln.Text);
cmd.Parameters.AddWithValue("@Email", txtmail.Text);
cmd.Parameters.AddWithValue("@Phoneno", txtphno.Text);
cmd.Parameters.AddWithValue("@DoB", txtdob.Text);
cmd.Parameters.AddWithValue("@Gender", txtgender.Text);
cmd.Parameters.AddWithValue("@Address", txtadd.Text);
cmd.Parameters.AddWithValue("@Qualification", txtqftn.Text);
cmd.Parameters.AddWithValue("@Experience", txtepnce.Text);
cmd.Parameters.AddWithValue("@Companyname",cboname.SelectedItem);
cmd.Parameters.AddWithValue("@Branch", cbobranch.SelectedItem);
cmd.Parameters.AddWithValue("@Position", cboafp.SelectedItem);
cmd.Parameters.AddWithValue("@Expsalary", txtepsy.Text);
con.Open();
cmd.ExecuteNonQuery();
MessageBox.Show("Register Sucessfully");
}
}
}

private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)


{
Form2 frm = new Form2();
frm.Show();

}
}
}
FORM 2

using System;
usingSystem.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace jobportal
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}

private void linkLabel1_LinkClicked (object sender, LinkLabelLinkClickedEventArgs e)


{
Form1 frm = new Form1();
frm.Show();

}
}
}
OUTPUT:

FORM1: HOME

FORM2: REGISTERATION
DATABASE TABLE:
RESULT:
Thus, the program job Portal has been successfully executed.

You might also like