Set 7
Set 7
import java.util.Scanner;
// Subclass: SavingsAccount
this.accountNumber = accountNumber;
this.accountHolderName = accountHolderName;
this.address = address;
this.balance = initialBalance;
this.rateOfInterest = rateOfInterest;
@Override
balance -= amount;
} else {
System.out.println("Insufficient balance.");
@Override
balance += amount;
}
// Display method for SavingsAccount
@Override
super.display();
// Subclass: CurrentAccount
this.accountNumber = accountNumber;
this.accountHolderName = accountHolderName;
this.address = address;
this.balance = initialBalance;
this.overdraftLimit = overdraftLimit;
@Override
balance -= amount;
} else {
System.out.println("Exceeds overdraft limit.");
@Override
balance += amount;
@Override
super.display();
System.out.print("Address: ");
String savingsAddress = scanner.nextLine();
System.out.print("Address: ");
savingsAccount.display();
scanner.close();
Output
Rate of Interest: 5
Q2
import java.util.Scanner;
array[i][j] = scanner.nextInt();
System.out.println("\nOriginal Array:");
System.out.println();
swappedArray[j][i] = array[i][j];
System.out.println();
scanner.close();
Output
Element [0][0]: 10
Element [0][1]: 20
Element [0][2]: 30
Element [1][0]: 40
Element [1][1]: 50
Element [1][2]: 60
Original Array:
10 20 30
40 50 60
10 40
20 50
30 60
Element [0][0]: 7
Element [0][1]: 8
Element [1][0]: 9
Element [1][1]: 10
Element [2][0]: 11
Element [2][1]: 12
Original Array:
78
9 10
11 12
7 9 11
8 10 12