0% found this document useful (0 votes)
74 views9 pages

Oop Assignment 01: Name: Ghazanfar Qarshi ROLL NO: 2020-BSCS-019 Sec: A

The document contains the code submissions and outputs for an OOP assignment by Ghazanfar Qarshi. It includes 3 code examples that perform calculations with different orders of operation and a payroll program. It also contains the code for 3 C# classes - a BankAccount class, an Accessors class using getters and setters, and the main methods to test them.

Uploaded by

Sahil Jagdesh
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)
74 views9 pages

Oop Assignment 01: Name: Ghazanfar Qarshi ROLL NO: 2020-BSCS-019 Sec: A

The document contains the code submissions and outputs for an OOP assignment by Ghazanfar Qarshi. It includes 3 code examples that perform calculations with different orders of operation and a payroll program. It also contains the code for 3 C# classes - a BankAccount class, an Accessors class using getters and setters, and the main methods to test them.

Uploaded by

Sahil Jagdesh
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/ 9

OOP ASSIGNMENT 01

NAME: GHAZANFAR QARSHI


ROLL NO: 2020-BSCS-019
SEC: A
Q.1(a)
(1)
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 = 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);

Console.WriteLine(" ENTER THE TOTAL HOURS WORKED BY BY SECOND EMPLOYEE:


");
bhrsworked = Console.ReadLine();
b = Convert.ToInt32(bhrsworked);

Console.WriteLine(" ENTER THE TOTAL HOURS WORKED BY BY THIRD EMPLOYEE:


");
chrsworked = Console.ReadLine();
c = Convert.ToInt32(chrsworked);

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;

public String nameOfCourse


{
get
{
return courseName;
}
set
{
courseName = value;
}
}
public string codeOfCourse
{
get
{
return courseCode;
}
set
{
courseCode = value;
}
}
}
class Program
{
static void Main(string[] args)
{
Accessors obj = new Accessors();
obj.nameOfCourse = "OOP-Lab";
obj.codeOfCourse = "CS-127";
Console.WriteLine("Course Name: " + obj.nameOfCourse);
Console.WriteLine("Course Code: " + obj.codeOfCourse);
Console.ReadKey();
}
}
}

OUTPUT:

You might also like