You are on page 1of 22

PRACTICAL 2A

Create simple application to perform following operations

i. Finding factorial Value

ii. Money Conversion

iii. Quadratic Equation

iv. Temperature Conversion

CODE:-
using System;

using System.Collections.Generic;

using System.Data;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace Practical_2a

internal class Program

static void Main(string[] args)

Console.WriteLine("Enter option for : \n 1. Factorial \n 2. Money Conversion \n 3.


Quadratic Equation \n 4. Temperature Conversion");

int option = int.Parse(Console.ReadLine());


switch (option)

case 1:

Console.WriteLine("Enter a number for factorial: ");

int number_1 = int.Parse(Console.ReadLine());

int factorial = number_1;

for (int i = number_1 - 1; i > 0; i--)

factorial = factorial * i;

Console.WriteLine(factorial);

Console.ReadLine();

break;

case 2:

Console.WriteLine("Enter 1 for USD to INR and 2 for EUR to INR");

int option_1 = int.Parse(Console.ReadLine());

switch(option_1)
{

case 1:

Console.WriteLine("Enter USD: ");

double usd = int.Parse(Console.ReadLine());

double rupees = usd * 82.29;

Console.WriteLine(rupees);

Console.ReadLine();

break;

case 2:

Console.WriteLine("Enter EUR: ");

double eur = int.Parse(Console.ReadLine());

double rupees_1 = eur * 90.41;

Console.WriteLine(rupees_1);

Console.ReadLine();

break;
}

break;

case 3:

Console.WriteLine("Value of a: ");

int a = int.Parse(Console.ReadLine());

Console.WriteLine("Value of b: ");

int b = int.Parse(Console.ReadLine());

Console.WriteLine("Value of c: ");

int c = int.Parse(Console.ReadLine());

double d = b * b - (4 * a * c);

if (d >= 0)

double result = Math.Sqrt(d);

double root1 = (-b + result)/(2*a);

double root2 = (-b - result) / (2 * a);


Console.WriteLine("This equation has real roots");

Console.WriteLine("x = " + root1);

Console.WriteLine("x = " + root2);

else

double dconvert = d * -1;

double result1 = Math.Sqrt(dconvert);

double real_value = (-b)/(2*a);

double imagvalue = result1 / (2 * a);

Console.WriteLine("This Equation has imaginary roots");

Console.WriteLine("x = " + real_value + " + " + imagvalue + "i");

Console.WriteLine("x = " + real_value + " - " + imagvalue + "i");

Console.ReadLine();

break;
case 4:

Console.WriteLine("Enter 1 for Degree to Far and 2 for Degree to Kel");

int option_2 = int.Parse(Console.ReadLine());

switch (option_2)

case 1:

Console.WriteLine("Enter Degree: ");

double deg_1 = int.Parse(Console.ReadLine());

double far = (deg_1 * 9/5) + 32 ;

Console.WriteLine(far);

Console.ReadLine();

break;

case 2:

Console.WriteLine("Enter Degree: ");


double deg_2 = int.Parse(Console.ReadLine());

double kel = deg_2 + 273.15;

Console.WriteLine(kel);

Console.ReadLine();

break;

Console.ReadLine() ;

break;

}
Output:-
i. Finding factorial Value

PRACTICAL 2A
Create simple application to perform following operations

i. Finding factorial Value

ii. Money Conversion

iii. Quadratic Equation

iv. Temperature Conversion

CODE:-
using System;

using System.Collections.Generic;

using System.Data;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace Practical_2a

internal class Program

static void Main(string[] args)

{
Console.WriteLine("Enter option for : \n 1. Factorial \n 2. Money Conversion \n 3.
Quadratic Equation \n 4. Temperature Conversion");

int option = int.Parse(Console.ReadLine());

switch (option)

case 1:

Console.WriteLine("Enter a number for factorial: ");

int number_1 = int.Parse(Console.ReadLine());

int factorial = number_1;

for (int i = number_1 - 1; i > 0; i--)

factorial = factorial * i;

Console.WriteLine(factorial);

Console.ReadLine();

break;

case 2:

Console.WriteLine("Enter 1 for USD to INR and 2 for EUR to INR");

int option_1 = int.Parse(Console.ReadLine());


switch(option_1)

case 1:

Console.WriteLine("Enter USD: ");

double usd = int.Parse(Console.ReadLine());

double rupees = usd * 82.29;

Console.WriteLine(rupees);

Console.ReadLine();

break;

case 2:

Console.WriteLine("Enter EUR: ");

double eur = int.Parse(Console.ReadLine());

double rupees_1 = eur * 90.41;

Console.WriteLine(rupees_1);

Console.ReadLine();
break;

break;

case 3:

Console.WriteLine("Value of a: ");

int a = int.Parse(Console.ReadLine());

Console.WriteLine("Value of b: ");

int b = int.Parse(Console.ReadLine());

Console.WriteLine("Value of c: ");

int c = int.Parse(Console.ReadLine());

double d = b * b - (4 * a * c);

if (d >= 0)

double result = Math.Sqrt(d);


double root1 = (-b + result)/(2*a);

double root2 = (-b - result) / (2 * a);

Console.WriteLine("This equation has real roots");

Console.WriteLine("x = " + root1);

Console.WriteLine("x = " + root2);

else

double dconvert = d * -1;

double result1 = Math.Sqrt(dconvert);

double real_value = (-b)/(2*a);

double imagvalue = result1 / (2 * a);

Console.WriteLine("This Equation has imaginary roots");

Console.WriteLine("x = " + real_value + " + " + imagvalue + "i");

Console.WriteLine("x = " + real_value + " - " + imagvalue + "i");

}
Console.ReadLine();

break;

case 4:

Console.WriteLine("Enter 1 for Degree to Far and 2 for Degree to Kel");

int option_2 = int.Parse(Console.ReadLine());

switch (option_2)

case 1:

Console.WriteLine("Enter Degree: ");

double deg_1 = int.Parse(Console.ReadLine());

double far = (deg_1 * 9/5) + 32 ;

Console.WriteLine(far);

Console.ReadLine();

break;

case 2:
Console.WriteLine("Enter Degree: ");

double deg_2 = int.Parse(Console.ReadLine());

double kel = deg_2 + 273.15;

Console.WriteLine(kel);

Console.ReadLine();

break;

Console.ReadLine() ;

break;

}
Output:-
i. Finding factorial Value

ii. Money Conversion

A) USD TO INR
B) EUR TO INR

iii. Quadratic Equation

A)IMAGINARY ROOTS
B) REAL ROOT

C)EQUAL AND REAL ROOT


iv. Temperature Conversion

A) DEGREE TO FAR

B) DEGREE TO KEN
ii. Money Conversion

A) USD TO INR

B) EUR TO INR
iii. Quadratic Equation

A)IMAGINARY ROOTS

B) REAL ROOT
C)EQUAL AND REAL ROOT

iv. Temperature Conversion


A) DEGREE TO FAR

B) DEGREE TO KEN

You might also like