Untitled
unknown
plain_text
5 months ago
2.7 kB
2
Indexable
import java.util.Scanner; interface Bank { // Bank properties and methods String getBankName(); double getRateOfInterest(); String getLocation(); String getServices(); } class SBI implements Bank { public String getBankName() { return "State Bank of India"; } public double getRateOfInterest() { return 5.4; } public String getLocation() { return "Mumbai, India"; } public String getServices() { return "Savings, Loans, Fixed Deposits, Insurance"; } } class HDFC implements Bank { public String getBankName() { return "HDFC Bank"; } public double getRateOfInterest() { return 6.5; } public String getLocation() { return "Mumbai, India"; } public String getServices() { return "Savings, Loans, Credit Cards, Mutual Funds"; } } class ICICI implements Bank { public String getBankName() { return "ICICI Bank"; } public double getRateOfInterest() { return 6.0; } public String getLocation() { return "Mumbai, India"; } public String getServices() { return "Savings, Loans, Forex, Wealth Management"; } } public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println("Welcome to the Bank Information System!"); System.out.println("Select a bank to explore:"); System.out.println("1. SBI\n2. HDFC\n3. ICICI"); System.out.print("Enter your choice: "); int choice = scanner.nextInt(); Bank selectedBank; // Using switch-case to assign the selected bank object switch (choice) { case 1: selectedBank = new SBI(); break; case 2: selectedBank = new HDFC(); break; case 3: selectedBank = new ICICI(); break; default: System.out.println("Invalid choice! Please try again."); scanner.close(); return; } // Displaying bank details System.out.println("\n--- Bank Details ---"); System.out.println("Bank Name: " + selectedBank.getBankName()); System.out.println("Interest Rate: " + selectedBank.getRateOfInterest() + "%"); System.out.println("Location: " + selectedBank.getLocation()); System.out.println("Services: " + selectedBank.getServices()); System.out.println("\nThank you for using the Bank Information System!"); scanner.close(); } }
Editor is loading...
Leave a Comment