Oop Assignment 01: Name: Ghazanfar Qarshi ROLL NO: 2020-BSCS-019 Sec: A
Oop Assignment 01: Name: Ghazanfar Qarshi ROLL NO: 2020-BSCS-019 Sec: A
Oop Assignment 01: Name: Ghazanfar Qarshi ROLL NO: 2020-BSCS-019 Sec: A
namespace OOPAssignment01
{
class Program
{
static void Main(string[] args)
{
double z;
z = 5 + 4 * 5 / 2 - 1;
Console.WriteLine(z);
Console.ReadLine();
}
}
}
OUTPUT:
ORDER OF EVALUATION:
Z=5+4*5/2–1
Z = 5 + 4 * 2.5 – 1
Z = 5 + 10 – 1
Z = 15 – 1
Z = 14 (ANSWER)
(2)
CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OOPAssignment01
{
class Program
{
static void Main(string[] args)
{
double z;
z = 3 % 3 + 4 * 4 - 2 / 2;
Console.WriteLine(z);
Console.ReadLine();
}
}
}
OUTPUT:
ORDER OF EVALUATION:
Z=3%3+4*4–2/2
Z=3%3+4*4–1
Z=0+4*4–1
Z = 16 – 1
Z = 15 (ANSWER)
(3)
CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OOPAssignment01
{
class Program
{
static void Main(string[] args)
{
double z;
z = (4 * 5 * (6 + (10 * 3 / (3))));
Console.WriteLine(z);
Console.ReadLine();
}
}
}
OUTPUT:
ORDER OF EVALUATION:
Z = (4 * 5 * (6 + (10 * 3 / (3))));
Z = (4 * 5 * (6 + (10 * 1))
Z = (4 * 5 * (6 + (10))
Z = (4 * 5 * (16))
Z = (4 * 80 )
Z = 320 (ANSWER
Q.1(b)
CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OOPAssignment01
{
class Program
{
static void Main(string[] args)
{
string ahrsworked;
string bhrsworked;
string chrsworked;
int a;
int b;
int c;
double agrosspay;
double bgrosspay;
double cgrosspay;
Console.WriteLine(" ENTER THE TOTAL HOURS WORKED BY BY FIRST EMPLOYEE:
");
ahrsworked = Console.ReadLine();
a = Convert.ToInt32(ahrsworked);
if (a <= 20)
{
agrosspay = a * 100;
Console.WriteLine(" THE GROSS PAY OF FIRST EMPLOYEE FOR (" + a + ")
HOURS IS RS:" + agrosspay);
}
else
{
agrosspay = a * 150;
Console.WriteLine(" THE GROSS PAY OF FIRST EMPLOYEE FOR (" + a + ")
HOURS IS RS:" + agrosspay);
}
if (b <= 20)
{
bgrosspay = b * 100;
Console.WriteLine(" THE GROSS PAY OF SECOND EMPLOYEE FOR (" + b + ")
HOURS IS RS:" + bgrosspay);
}
else
{
bgrosspay = b * 150;
Console.WriteLine(" THE GROSS PAY OF SECOND EMPLOYEE FOR (" + b + ")
HOURS IS RS:" + bgrosspay);
}
if (c <= 20)
{
cgrosspay = c * 100;
Console.WriteLine(" THE GROSS PAY OF THIRD EMPLOYEE FOR (" + c + ")
HOURS IS RS:" + cgrosspay);
}
else
{
cgrosspay = c * 150;
Console.WriteLine(" THE GROSS PAY OF THIRD EMPLOYEE FOR (" + c + ")
HOURS IS RS:" + cgrosspay);
}
Console.ReadLine();
}
}
}
OUTPUT:
Q.2
CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OOPAssignment01
{
public class BankAccount
{
public String nameOfTheDepositor;
public int accountNo;
public int withdrawalAmount;
public int balanceAmount;
public void assignInitialValues()
{
string s;
Console.WriteLine("Enter Depositor's Name: ");
nameOfTheDepositor = Console.ReadLine();
Console.WriteLine("Enter Account No: ");
s = Console.ReadLine();
accountNo = Convert.ToInt32(s);
Console.WriteLine("Enter your Account Balance: ");
s = Console.ReadLine();
balanceAmount = Convert.ToInt32(s);
}
public void deposit()
{
string s;
int depositAmount;
Console.WriteLine("\n");
Console.WriteLine("Enter the Amount You Want to Deposit: ");
s = Console.ReadLine();
depositAmount = Convert.ToInt32(s);
balanceAmount = balanceAmount + depositAmount;
Console.WriteLine("Your New Account Balance after Depositing {0}$ is:
{1}$",depositAmount,balanceAmount);
}
public void withdraw()
{
string s;
Console.WriteLine("\n");
Console.WriteLine("Enter the Amount You Want to Withdraw: ");
s = Console.ReadLine();
withdrawalAmount = Convert.ToInt32(s);
balanceAmount = balanceAmount - withdrawalAmount;
Console.WriteLine("After Withdrawing {0}$ Now Your Current Account
Balance is: {1}$ ",withdrawalAmount,balanceAmount);
}
public void display()
{
Console.WriteLine("\n");
Console.WriteLine("Depositor's Name: {0}",nameOfTheDepositor);
Console.WriteLine("Current Balance: {0}$",balanceAmount);
}
}
class Program
{
static void Main(string[] args)
{
BankAccount ghazanfar = new BankAccount();
ghazanfar.assignInitialValues();
ghazanfar.deposit();
ghazanfar.withdraw();
ghazanfar.display();
Console.ReadKey();
}
}
}
OUTPUT:
Q.3
CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication4
{
public class Accessors
{
private String courseName;
private string courseCode;
OUTPUT: