0% found this document useful (0 votes)
8 views8 pages

3 Programs

Uploaded by

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

3 Programs

Uploaded by

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

EX.

NO:2 (b) Arithmetic Operations using Classes and Objects

Program:

using System;

namespace Operation

class Program

static void Main(string[] args)

double a, b, w, x, y, z;

Console.Write("Enter first number: ");

a = Convert.ToDouble(Console.ReadLine());

Console.Write("Enter second number: ");

b = Convert.ToDouble(Console.ReadLine());

w = a + b;

x = a - b;

y = a * b;

z = a / b;

Console.WriteLine("Addition: "+w);
Console.WriteLine("Subtraction: "+x);

Console.WriteLine("Multiplication: "+y);

Console.WriteLine("Division: "+z);

Console.ReadKey();

Output:

5(B)

Program:

namespace Online_Application

class Program

static void Main(string[] args)

EnterName ename = new EnterName();

ename.ev_BannedUser += WarningAlarm;
ename.User();

Console.Read();

static void WarningAlarm(object sender, BannedUserEventArgs e)

Console.WriteLine("{0} Users Found. Sending Email to Administration.", e.Name);

Console.WriteLine("Email Sent.");

Console.WriteLine("Warning Alarm Started.");

Console.WriteLine("Press Ctrl + c to stop the alarm");

for (;;)

Console.Beep();

System.Threading.Thread.Sleep(100);

public class EnterName

public event EventHandler<BannedUserEventArgs> ev_BannedUser;

public void User()

Console.Write("Enter You Name : ");

string user = Console.ReadLine();

if ((user == "Jack" || user == "Steven" || user == "Mathew") && (ev_BannedUser!=null))

{
ev_BannedUser(this, new BannedUserEventArgs(user));

else

Console.WriteLine("Welcome to " + user);

public class BannedUserEventArgs : EventArgs

public BannedUserEventArgs(string s)

Name = s;

public string Name { get;set;}

Output:
3)(b)

Program:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace Exercise

class Program

static void Main(string[] args)

Laptop lp = new Laptop();


lp.ShowDetails(Laptop.Lenove, Laptop.Price1000, Laptop.i3, Laptop.Ram2GB,
Laptop.HD500GB);

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

lp.ShowDetails(Laptop.Dell, Laptop.Price1500, Laptop.i5, Laptop.Ram4GB, Laptop.HD1TB);

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

lp.ShowDetails(Laptop.Sony, Laptop.Price2000, Laptop.i9, Laptop.Ram8GB, Laptop.HD1TB);

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

Console.ReadKey();

class Laptop : LaptopBase

public void ShowDetails(string name, string price, string processor, string ram, string hdd)

Console.WriteLine("Name : "+name);

Console.WriteLine("Price : " + price);

Console.WriteLine("Processor : " + processor);

Console.WriteLine("Ram : " + ram);

Console.WriteLine("HDD : " + hdd);

class LaptopBase

public const string i3 = "i3";


public const string i5 = "i5";

public const string i7 = "i7";

public const string i9 = "i9";

public const string Ram2GB = "2GB";

public const string Ram4GB = "4GB";

public const string Ram8GB = "8GB";

public const string HD500GB = "500GB";

public const string HD1TB = "1TB";

public const string Price1000 = "$1000";

public const string Price1500 = "$1500";

public const string Price2000 = "$2000";

public const string Lenove = "Lenovo";

public const string Sony = "Sony";

public const string Dell = "Dell";

Output:

You might also like