Jiwaji University Gwalior: (2021-2023) Mba E-Com 2 SEM
Jiwaji University Gwalior: (2021-2023) Mba E-Com 2 SEM
Gwalior
.NET Technologies
(2021-2023)
Mba E-com 2 SEM
nd
OUTPUT:
2. Write an application that obtains two numbers from the user, and displays
them, but rejects any input where both numbers are greater than 10 and asks
for two new numbers.
CODE
using System;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
int var1, var2;
label1:
Console.Write("Enter number 1: ");
var1 = Int32.Parse(Console.ReadLine());
Console.Write("Enter number 2: ");
var2 = Convert.ToInt32(Console.ReadLine());
if ((var1 > 10 && var2 > 10) )
{
Console.WriteLine("Both No are greater than 10 are not allowed"); goto label1;
}
else
{
Console.WriteLine("Number 1: "+var1);
Console.WriteLine("Number 2 :"+var2);
Console.WriteLine("This code is run by SURUCHI");
}
}
}
}
OUTPUT:
OUTPUT:
OUTPUT:
b. Generate various patterns (triangles, diamond and other patterns) with
numbers.
CODE:
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int row, col;
for (row = 1; row <= 5; row++)
{
for (col = 1; col <= row; col++)
Console.Write(col);
Console.WriteLine();
}
Console.WriteLine("This code is run by SURUCHI");
}
}
}
OUTPUT:
c. Test for prime numbers.
CODE:
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int row, sp, col,revcol;
for (row = 1; row <= 5; row++)
{
for (sp = 1; sp <= 5 - row; sp++)
{
Console.Write(' ');
}
for (col = 1; col <= row; col++)
{
Console.Write(col);
}
for (revcol = col - 2; revcol >= 1; revcol--)
{
Console.Write(revcol);
}
Console.WriteLine();
}
Console.WriteLine("This code is run by SURUCHI");
}
}
}
OUTPUT:
OUTPUT:
e. Reverse a number and find sum of digits of a number.
CODE:
using System;
namespace reverseNumber
{
class Program
{
static void Main(string[] args)
{
int num,actualnumber,revnum=0,digit,sumDigits=0;
Console.Write("Enter number:"); num =
int.Parse(Console.ReadLine());
actualnumber = num;
while (num > 0)
{
digit = num % 10;
revnum = revnum * 10 + digit;
sumDigits=sumDigits+digit;
num = num / 10;
}
Console.WriteLine("Reverse of " + actualnumber + "=" +revnum);
Console.WriteLine("Sum of its digits:" + sumDigits);
Console.WriteLine("This code is run by SURUCHI");
}
}
}
OUTPUT:
5. Write a program to declare a class „staff‟ having data members as name
and post.accept this data 5for 5 staffs and display names of staff who are
HOD.
CODE:
using System;
namespace staff
{
class staff
{
string name, post;
public void getdata()
{
Console.Write("Enter name and post:");
name = Console.ReadLine();
post = Console.ReadLine();
}
public void display()
{
Console.WriteLine(name + "\t\t" + post);
}
public string getPost()
{
return post;
}
}
class program
{
static void Main(string[] args)
{
staff[] objStaff = new staff[5];
int i;
for (i = 0; i < 5; i++)
{
objStaff[i] = new staff();
objStaff[i].getdata();
}
Console.WriteLine("Name \t\t Post");
for (i = 0; i < 5; i++)
{
if (objStaff[i].getPost() == "HOD")
objStaff[i].display();
}
Console.WriteLine("This code is run by SURUCHI");
}
}
}
OUTPUT:
6. Write a program using function overloading to swap two integer numbers
and swap two float numbers.
CODE:
using System;
namespace swap
{
class Overloading
{
public void swap(ref int n, ref int m)
{
int t;
t = n;
n = m;
m = t;
}
public void swap(ref float f1, ref float f2)
{
float f;
f = f1;
f1 = f2;
f2 = f;
}
}
class program
{
static void Main(string[] args)
{
Overloading objOverloading = new Overloading();
int n = 20, m = 10;
objOverloading.swap(ref n, ref m);
Console.WriteLine("N=" + n + "\tM=" + m);
float f1 = 10.5f, f2 = 20.6f;
objOverloading.swap(ref f1, ref f2);
Console.WriteLine("F1=" + f1 + "\tF2=" + f2);
Console.WriteLine("This code is run by Suruchi");
}
}
}
OUTPUT:
7. Define a class „salary‟ which will contain member variable Basic, TA, DA,
HRA. Write a program using Constructor with default values for DA and
HRA and calculate the salary of employee.
CODE:
using System;
namespace SalaryConstructure
{
class Salary
{
int basic, ta, da, hra;
public Salary()
{
da = 9000;
hra = 6000;
}
public void getdata()
{
Console.Write("Enter basic salary : "); basic =
int.Parse(Console.ReadLine());
Console.Write("Enter travelling allowance : ");
ta = int.Parse(Console.ReadLine());
}
public void showdata()
{
Console.WriteLine("Basic salary : " + basic);
Console.WriteLine("Dearness allowence : " + da);
Console.WriteLine("Housing rent allowence : " + hra);
Console.WriteLine("Travelling allowence : " + ta);
Console.WriteLine("Gross Salary : " + (basic + da + hra + ta));
}}
class Program
{
static void Main(string[] args)
{
Salary s = new Salary();
s.getdata();
s.showdata();
}}}
OUTPUT:
8. Create an application that allows the user to enter a number in the textbox
named „getnum‟. Check whether the number in the textbox „getnum‟ is
palindrome or not. Print the message accordingly in the label control named
lbldisplay when the user clicks on the button „check‟.
CODE:
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace PalindromeCheck
{
public partial class PalindromeNumberCheck : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btncheck_Click(object sender, EventArgs e)
{
int num = int.Parse(getNum.Text);
int n, rev = 0, d;
n = num;
while (n > 0)
{
d = n % 10;
n = n / 10;
rev = rev * 10 + d;
}
if (rev == num)
lblnum2.Text = lblnum2.Text + num + " is a
Palindrome number."; else
lblnum2.Text = lblnum2.Text + num + " is not a Palindrome number.";
}}}
OUTPUT:
9. Create an application which will ask the user to input his name and a
message, display the two items concatenated in a label, and change the format
of the label using radio buttons and check boxes for selection , the user can
make the label text bold ,underlined or italic and change its color . include
buttons to display the message in the label, clear the text boxes and label and
exit.
CODE:
using System;
namespace DisplayMessage
{
public partial class DisplayTheMessage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btndisplay_Click(object sender, EventArgs e)
{
if (chkbold.Checked == true)
lblDisplay.Font.Bold = true;
else
lblDisplay.Font.Bold = false;
if (chkitalic.Checked == true)
lblDisplay.Font.Italic = true;
else
lblDisplay.Font.Italic = false;
if (chkunderline.Checked == true)
lblDisplay.Font.Underline = true;
else
lblDisplay.Font.Underline = false;
if (rbred.Checked == true)
lblDisplay.ForeColor = System.Drawing.Color.Red;
else if(rbgreen.Checked == true)
lblDisplay.ForeColor = System.Drawing.Color.Green;
else if (rbpink.Checked == true)
lblDisplay.ForeColor = System.Drawing.Color.Pink;
lblDisplay.Text = "Name:" + txtName.Text + "<br/>" + "Message:" +
txtMessage.Text;
}}}
OUTPUT:
10. “How is the book ASP.NET with c# by Deepak Prakashan?” Give the user three choice:
i) Good ii) Satisfactory iii)Bad. Provide a VOTE button. After user votes, present the result
in percentage using labels next to the choices.
CODE:
using System;
namespace feedback
{
public partial class feedbackselect : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnvote_Click(object sender, EventArgs e)
{
if (rdogood.Checked == true)
{
int goodCount;
if (ViewState["gcount"] != null)
goodCount = Convert.ToInt32(ViewState["gcount"]) + 1;
else
goodCount = 1;
ViewState["gcount"] = goodCount;
}
if (rdosatisfactory.Checked == true)
{
int satisfactoryCount;
if (ViewState["scount"] != null)
satisfactoryCount = Convert.ToInt32(ViewState["scount"]) + 1;
else
satisfactoryCount = 1;
ViewState["scount"] = satisfactoryCount;
}
if (rdobad.Checked == true)
{
int badCount;
if (ViewState["bcount"] != null)
badCount = Convert.ToInt32(ViewState["bcount"]) +
1; else
badCount = 1;
ViewState["bcount"] = badCount;
}
int totalCount;
if (ViewState["count"] != null)
totalCount = Convert.ToInt32(ViewState["count"]) +
1; else
totalCount = 1;
ViewState["count"] = totalCount;
double gper = (Convert.ToDouble(ViewState["gcount"]) /
Convert.ToDouble(ViewState["count"])) * 100.0f;
lblgood.Text = gper.ToString() + "%";
double sper = (Convert.ToDouble(ViewState["scount"])
/ Convert.ToDouble(ViewState["count"])) * 100.0f;
lblsatisfactory.Text = sper.ToString() + "%";
double bper = (Convert.ToDouble(ViewState["bcount"]) /
Convert.ToDouble(ViewState["count"])) * 100.0f;
lblbad.Text = bper.ToString()+"%";
}}}
OUTPUT:
11.Create the application that accepts name, password, age , email id, and user id. Allthe
information entry is compulsory. Password should be reconfirmed. Age should be within
21 to 30. Email id should be valid. User id should have at least a capital letter and digit as
well as length should be between 7 and 20 characters.
CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace ValidationControl
{
public partial class ValidationControlForm : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void CustomValidator1_ServerValidate(object
source, ServerValidateEventArgs args)
{
string str = args.Value;
args.IsValid = false;
if (str.Length < 7 || str.Length > 20)
{
return;
}
bool capital = false;
foreach (char ch in str)
{
if (ch >= 'A' && ch <= 'Z')
{
capital = true;
break;
}
}
if (!capital)
return;
bool digit = false;
foreach (char ch in str)
{
if (ch >= '0' && ch <= '9')
{
digit = true;
break;
}
}
if (!digit)
return;
args.IsValid = true;
}
protected void btnSubmit_Click(object sender, EventArgs e)
{ }}}
OUTPUT: