Ooops 11
Ooops 11
// Area of rectangle: length * breadth System.out.println(“Rectangle Area: “ + shape.area(length, breadth)); String acno; // Account number
Public double area(double length, double breadth) { String name; // Account holder’s name
// Area of triangle: 0.5 * base * height System.out.print(“Enter height of triangle: “); This.name = name;
Public double area(double base, double height, boolean isTriangle) { Double height = Double.parseDouble(reader.readLine()); }
Return -1; // Invalid case System.out.print(“Enter radius of circle: “); Double balance;
// Area of circle: π * radius * radius } Public Savings(String acno, String name, double initialBalance) {
Return Math.PI * radius * radius; This.balance = initialBalance >= MIN_BALANCE ? initialBalance : MIN_BALANCE;
} }
System.out.println(“Error: Insu icient balance or withdrawal would go below minimum balance.”); System.out.println(“3. Display Balance”); }
} System.out.println(“4. Exit”); }
} Account.deposit(depositAmount);
Break;
Public static void main(String[] args) throws IOException { System.out.print(“Enter withdrawal amount: “);
Break;
Exit = true;
Savings account = new Savings(acno, name, 1500); // Initial balance 1500 Break;
Default:
Throw new ArithmeticException(“Not eligible: Marks in one or more subjects below 60%”);
Public static void main(String[] args) throws IOException { Throw new ArithmeticException(“Not eligible: Total percentage below 50%”); String regNo; // Registration number
Obj.calculate();
} System.out.println(“Eligible. Total Percentage: “ + percentage + “%”); Public Student(String regNo, String name) {
} This.regNo = regNo;
Try {
System.out.print(“Enter Math marks: “); Public CE_Marks(String regNo, String name, double ceMarks) {
This.ceMarks = ceMarks;
Double total = math + phy + chem; Public ESE_Marks(String regNo, String name, double ceMarks, double eseMarks) {
This.eseMarks = eseMarks;
Return (ceMarks / 50.0) * 100 + (eseMarks / 75.0) * 100; Bu eredReader br = new Bu eredReader(isr);
} Interface Savings {
Public String calculateGrade() { System.out.print(“Enter Registration Number: “); Double MIN_BAL = 500;
} else if (totalMarks >= 70) { System.out.print(“Enter CE Marks (out of 50): “); String acno;
} else if (totalMarks >= 50) { System.out.print(“Enter ESE Marks (out of 75): “); String address;
} else {
Return “F”; // Create an instance of ESE_Marks and display the details Account(String acno, String name, String address, double bal) {
} This.address = address;
System.out.println(“Name: “ + name);
} } else {
}
} System.out.print(“Enter Address: “);
If (amount > 0 && (bal – amount) >= MIN_BAL) { Double bal = Double.parseDouble(br.readLine()); Break;
Bal -= amount;
System.out.println(“Withdrawn: “ + amount); Account account = new Account(acno, name, addr, bal); Case 4:
System.out.println(“Cannot withdraw. Balance would fall below minimum.”); Boolean running = true; System.out.println(“Exiting…”);
} Switch (choice) {
} Case 1: