You are on page 1of 11

Assignment no # 1

Section “A”
Department :
Software Engineering
Submitted to :
Sir Ashir
Submitted by :
Shahzaib ishtiaq(21011598-058)
Muhammad Farooq(21011598-019)

Corse Title: Object orienteg programing


Assignment no #1
Qno1

import java.util.Scanner;
import java.lang.Math;
public class Calculator {
static int a;
static int b;
static double c;
static int sum(int a,int b)
{

int sum=a+b;
return sum;
}
static int Mul(int a,int b)
{

int mul=a*b;
return mul;
}
static double Divide(int a,int b)
{

double div=a/b;
return div;
}
static int Mod(int a,int b)
{

int Mod=a%b;
return Mod;
}
static double sin(double c)
{
double sinis=Math.sin(c);
return sinis;
}
static double cos(double c)
{
double cosin=Math.cos(c);
return cosin;
}

static double tan(double c)


{
double tangent=Math.tan(c);
return tangent;
}
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("entre the first value");
int x= sc.nextInt();
System.out.println("entre the Second value");
int y=sc.nextInt();
System.out.println("Enter the value to perform the trigonometeric function sin,cos tan");
double z=sc.nextInt();
System.out.println("the sum is");
System.out.println(Calculator.sum(x,y));
System.out.println("The Multiplication is ");
System.out.println(Calculator.Mul(x,y));
System.out.println("Th division is ");
System.out.println(Calculator.Divide(x,y));
System.out.println("the mod is ");
System.out.println(Calculator.Mod(x,y));
System.out.println("Cos is ");
System.out.println(Calculator.cos(z));
System.out.println("Sin is ");
System.out.println(Calculator.sin(z));
System.out.println("Tan is ");
System.out.println(Calculator.tan(z));
}
}

Qno 2

package car;

public class Car {


private int wheel;
private int door;
public int speed;
Car()
{
wheel=4;
door=2;
speed=40;
}
Car(int wheel,int door)
{
this.wheel=wheel;
this.door=door;
}
int carspeedincrease(int speed){
int sp=speed+5;
return sp;
}
int carbreak(int speed){
int sp=speed-5;
return sp;
}

public static void main(String[] args) {

Car Hino=new Car(10,4);


System.out.println("the wheel are "+ Hino.wheel+" door are " +Hino.door);
System.out.println("th speed increase Hino five time");
System.out.println(Hino.carspeedincrease(40));
System.out.println("when a break time decrease a speed");
System.out.println(Hino.carbreak(40));
Car Ferrari=new Car(4,2);
System.out.println("the wheel is "+Ferrari.wheel+"the door is "+Ferrari.door);
System.out.println("the speed ferrari increase five time");
System.out.println(Ferrari.carspeedincrease(40));
System.out.println("when a break time decrease a speed");
System.out.println(Ferrari.carbreak(40));
}
}

Qno 3

public class Maximum {


public double max(double x, double y) {
double max;
double number1 = x;
double number2 = y;
if (number1 > number2) {
max= number1;
} else {
max = number2;
}
return max;
}

public double max(double x, double y, double z) {


double max;
double number1 = x;
double number2 = y;
double number3 = z;
if (number1 > number2 & number1 > number3) {
max= number1;
} else if (number2 > number1 & number2 > number3) {
max = number2;
} else {
max = number3;
}
return max;
}

public double max(double x, double y, double z, double w) {


double max;
double number1 = x;
double number2 = y;
double number3 = z;
double number4 = w;
if (number1 > number2 & number1 > number3 & number1 > number4) {
max= number1;
} else if (number2 > number1 & number2 > number3 & number2 > number4) {
max = number2;
} else if (number3 > number1 & number3 > number2 & number3 > number4) {
max = number3;
} else {
max= number4;
}
return max;
}

public double max(double x, double y, double z, double w, double k) {


double max;
double number1 = x;
double number2 = y;
double number3 = z;
double number4 = w;
double number5 = k;
if (number1 > number2 & number1 > number3 & number1 > number4 & number1 > number5) {
max = number1;
} else if (number2 > number1 & number2 > number3 & number2 > number4 & number2 >
number5) {
max= number2;
} else if (number3 > number1 & number3 > number2 & number3 > number4 & number3 >
number5) {
max = number3;
} else if (number4 > number1 & number4 > number2 & number4 > number3 & number4 >
number5) {
max = number4;
} else {
max = number5;
}
return max;
}

}
class Main {
public static void main(String[] args)
{
Maximum ans=new Maximum();
double res= ans.max(54, 77);
System.out.println(res);
System.out.println(ans.max(33.5,29,74));
System.out.println(ans.max(38.9,7.4,98.3,44));
System.out.println(ans.max(34,45,56,67,78));
}
}

Qno4

import java.util.Scanner;
public class Bank {
private int Account_no;
private double Balance;

public void SetAccount_no(int account_no) {


Account_no = account_no;
}

public int GetAccount_no() {


return Account_no;
}
public void SetBalance(double balance) {
Balance = balance;
}

public double GetBalance() {


return Balance;
}

Bank(int Account_no,double Balance)


{
this.Account_no=Account_no;
this.Balance=Balance;
}
void display(){
System.out.println("the Balance is "+Balance);
System.out.println("the account_no is "+Account_no);
}
double widrawamount()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the amount you want to widraw");
double wid=sc.nextDouble();

if(wid<=Balance){
Balance=Balance-wid;
}
System.out.println("youre current ballance is");
return Balance;
}
double Depositamount()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the amount you want to Deposit");
double dep=sc.nextDouble();
Balance=Balance+dep;
System.out.println("your current ballance is");
return Balance;
}

public static void main(String[] args) {


Bank costomer1=new Bank(2244,50000);
System.out.println("costomer1. BankAccount detail");
costomer1.display();
System.out.println(costomer1.widrawamount());
System.out.println(costomer1.Depositamount());
System.out.println("costomer2. BankAccount detail");
Bank costomer2 =new Bank(3344,40000);
costomer2.display();
System.out.println(costomer2.widrawamount());
System.out.println(costomer2.Depositamount());
}
}

You might also like