AWP Practical 1
AWP Practical 1
AWP Practical 1
a) Create an application that obtains four int values from the user and displays the
product.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplDiv2
{
class product
{
Static void Main (string [] args)
{
Console.WriteLine ("enter1st no’s");
int a = Convert.ToInt32 (Console.ReadLine());
Console.WriteLine (a*b*c*d);
Console.ReadLine ();
}
}
}
Output:-
Page 1
T.Y.B.Sc. (I.T.) – Advanced Web Programming –Paper (III) [Your Roll No]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleAppDiv2
class @string
Page 2
T.Y.B.Sc. (I.T.) – Advanced Web Programming –Paper (III) [Your Roll No]
String S2 = "topper";
ans = S1.ToUpper();
Console.WriteLine(ans);
ans = S1.Trim();
Console.WriteLine(ans);
Console.WriteLine(ans);
ans = S1.ToLower();
Console.WriteLine(ans);
ans = String.Concat(S1,S2);
Console.WriteLine(ans);
bool b=S1.EndsWith("g");
Console.WriteLine(b);
int a=S2.CompareTo(S1);
Console.WriteLine(a);
S3=String.Copy(S1);
Console.WriteLine(S3);
Console.Read();
Output:-
Page 3
T.Y.B.Sc. (I.T.) – Advanced Web Programming –Paper (III) [Your Roll No]
c) Create an application that receives the (Student Id, Student Name, Course Name, Date of
Birth) information from a set of students. The application should also display the information
of all the students once the data entered.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleAppDiv2
{
class STUDENT
{
static void Main(string[] args)
{
int s_id, i;
string name, cname, DOB;
int[] id = new int[10];
string[] s_name = new string[10];
string[] c_name = new string[10];
string[] D_O_B = new string[10];
for (i = 0; i < 2; i++)
{
Console.WriteLine("enter student ID");
s_id = Convert.ToInt32(Console.ReadLine());
id[i] = s_id;
Page 4
T.Y.B.Sc. (I.T.) – Advanced Web Programming –Paper (III) [Your Roll No]
Output:-
Page 5
T.Y.B.Sc. (I.T.) – Advanced Web Programming –Paper (III) [Your Roll No]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleAppDiv2
{
class p1e3
{
static void Main(string[] args)
{
p1e3 p = new p1e3();
int a;
Console.WriteLine("1.Fibonacci 2.Prime or not 3.Vowel 4.for-each loop
5.Sum of digits of number 6.Reverse");
Console.WriteLine("Enter your choice");
a = Convert.ToInt32(Console.ReadLine());
switch (a)
{
case 1:
{
p.fibo();
break;
}
case 2:
{
p.prime();
break;
}
case 3:
{
p.vowel();
break;
}
case 4:
{
p.fe();
break;
}
case 5:
{
p.sum();
break;
}
case 6:
{
p.reverse();
break;
}
default:
{
Console.WriteLine("Try again");
break;
}
}
}
public void fibo()
{
int n, f = 0, s = 1, c, next;
Console.WriteLine("Enter the no. of terms");
n = Convert.ToInt32(Console.ReadLine());
Page 6
T.Y.B.Sc. (I.T.) – Advanced Web Programming –Paper (III) [Your Roll No]
Console.WriteLine("Fibbo series");
for (c = 0; c < n; c++)
{
if (c <= 1)
{
next = c;
}
else
{
next = f + s;
f = s;
s = next;
}
Console.WriteLine("{0}", next);
}
Console.ReadLine();
}
public void prime()
{
int n, flag = 0;
int p = 2;
Console.WriteLine("Enter a number");
n = Convert.ToInt32(Console.ReadLine());
while (n != p)
{
if (n % p == 1)
{
flag++;
}
p++;
}
if (flag == 1)
{
Console.WriteLine("Number is not prime");
}
else
{
Console.WriteLine("Number is prime");
}
Console.ReadLine();
}
public void vowel()
{
char t;
Console.WriteLine("enter an alphabet");
t = Convert.ToChar(Console.ReadLine());
if (t == 'a' || t == 'e' || t == 'i' || t == 'o' || t == 'u')
{
Console.WriteLine("the character is a vowel");
}
else
{
Console.WriteLine("not a vowel");
}
Console.Read();
}
public void fe()
{
string[] str = { "it", "cs", "math" };
foreach (string i in str)
{
Page 7
T.Y.B.Sc. (I.T.) – Advanced Web Programming –Paper (III) [Your Roll No]
Console.WriteLine(i);
Console.Read();
}
}
Console.WriteLine("sum of digits of the number:");
Console.Read();
}
}
}
Output:-
Page 8
T.Y.B.Sc. (I.T.) – Advanced Web Programming –Paper (III) [Your Roll No]
Page 9
T.Y.B.Sc. (I.T.) – Advanced Web Programming –Paper (III) [Your Roll No]
Page 10