assignment1
assignment1
ASSIGNMENT 1
NAME: M Mubashir Hassan (FA23-BAI-
034)
CLASS: BSAI
SEMESTER: 4th
SUBJECT: OOP
DATED: 05-03-2025
COMSATS UNIVERSITY
ISLAMABAD,ISLAMABAD CAMPUS
Question #1
Source Code
import java.util.Scanner;
class Worker {
private String name;
private int hoursWorked;
private double hourlyWage;
worker1.displayWorkerDetails();
worker2.displayWorkerDetails();
}
}
Output
Question # 2
Source Code
class QuadraticEquation {
private double a, b, c;
public QuadraticEquation() {
this.a = 1;
this.b = 1;
this.c = 1;
}
class Main {
public static void main(String[] args) {
QuadraticEquation equation1 = new QuadraticEquation(2, 5, 3);
equation1.display();
System.out.println("Is discriminant > 100? "
+ equation1.checkIfDiscriminantIsGreaterThan100());
Output
Question # 3
Source Code
class SavingsAccount {
private static double annualInterestRate;
private double savingsBalance;
saver1.calculateMonthlyInterest();
saver2.calculateMonthlyInterest();
saver1.calculateMonthlyInterest();
saver2.calculateMonthlyInterest();