AWP Practical Assignment 1: Name: Pravin Patel Sap: 53003180119
AWP Practical Assignment 1: Name: Pravin Patel Sap: 53003180119
Name: Pravin Patel
Sap: 53003180119
1. Write an application which 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.
using System;
namespace ConsoleApplication2
{
public class Program
{
public static void Main(string[] args)
{
int var1, var2;
label1:
Console.Write("Pravin");
Console.Write("Sap-53003180119");
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);
}
}
}
}
2. Writea console application that places double quotation marks around each word in a
string?
using System;
namespace ConsoleApplication3
{
public class Program
{
public static void Main(string[] args)
{
Console.Write("Pravin");
Console.Write("Sap-53003180119");
string str1;
Console.Write("Enter string 1: ");
str1 = Console.ReadLine();
string[] words = str1.Split(' ');
for (int i = 0; i < words.Length; i++)
{
Console.Write("\" " + words[i] + "\" ");
}
}
}
}
Write a program to declare a class ‘staff’ having data members as name and post. Accept
this data for 5 staffs and display names of staff who are HOD.
using System;
namespace staff
{
class staff
{
Console.Write("Pravin");
Console.Write("Sap-53003180119");
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;
}
}
public class program
{
public 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();
}
}
}
}
4. List
of employees is available in listbox. Write an application to add selected or all
records from listbox (assume multi-line property of textbox is true).
using System;
namespace list
{
public partial class listselect : System.Web.UI.Page
{
Console.Write("Pravin");
Console.Write("Sap-53003180119");
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnAdd_Click(object sender, EventArgs e)
{
int i;
for (i = 0; i < lstEmployee.Items.Count; i++)
{
if (lstEmployee.Items[i].Selected == true)
txtEmployee.Text += lstEmployee.Items[i].Text + "\n";
}
}
}
}