Dot Net - Lab Vi
Dot Net - Lab Vi
(AUTONOMOUS)
COIMBATORE-18
SEMESTER VI
(AUTONOMOUS)
COIMBATORE-18
SEMESTER VI
Certified Bonafide record of practical work done during the year 2024-2025
REGISTER NO:
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:
ALGORITHM:
STEP 5: Format and Print various date and time formats using ToString() method:
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...".
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());
}
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.
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();
}
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 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.
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();
}
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");
}
}
textBox1.Text=phonebook.Rows[dataGridView1.CurrentCell.RowIndex].ItemArray[0].ToString();
textBox2.Text=phonebook.Rows[dataGridView1.CurrentCell.RowIndex].ItemArray[1].ToString();
}
}
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 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 8: Open Form2 in the designer view. From the toolbox, drag and drop two
Label controls onto the form:.
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 REGISTRATION()
{
InitializeComponent();
}
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:
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 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.
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
{
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 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.
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;
}
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.
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");
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:
ALGORITHM:
STEP 1: Open Visual Studio 2012 and create new windows form application.
STEP 3: Initialize variables m1, m2, m3, m4, Total, and Percentage.
STEP 5: Add controls like text boxes and buttons for input and output.
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 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".
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();
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:
ALGORITHM:
STEP 1: Start the process. Open Visual Studio 2012 and create New console applicaton.
STEP 4: Read and store the Customer ID (ID) from the user.
STEP 6: Read and store the Customer Name (Name) from the user.
STEP 9 : Read and store the consumed units (Unit) from the user.
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");
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 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
STEP 7: Calculate and display the consumed units by subtracting the previous reading
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();
}
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 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 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.
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();
}
}
}
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();
}
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 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 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 11: Add parameters to the SQL command for user input data obtained from
STEP 13: Execute the SQL command to insert the user registration data.
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();
}
}
}
}
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();
}
}
}
}
OUTPUT:
FORM1: HOME
FORM2: REGISTERATION
DATABASE TABLE:
RESULT:
Thus, the program job Portal has been successfully executed.