Create a Java program to demonstrate the use of an interface for custom currency conversion
interface CurrencyConverter { double convertCurrency(double amount, String fromCurrency, String toCurrency); } public class Main { public static void main(String[] args) { CurrencyConverter currencyConverter = new CurrencyConverter() { @Override public double convertCurrency(double amount, String fromCurrency, String toCurrency) { // Implement currency conversion logic here // For simplicity, we'll return the same amount without conversion return amount; } }; double amount = 25000.0; String fromCurrency = "USD"; String toCurrency = "EUR"; double convertedAmount = currencyConverter.convertCurrency(amount, fromCurrency, toCurrency); System.out.println("Converted Amount : " + convertedAmount + " " + toCurrency); } }
Converted Amount : 25000.0 EUR
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions