// CurrencyConverterKL.java Copyright (c) 2006 Kari Laitinen // http://www.naturalprogramming.com // 2006-02-12 File created. // 2006-02-12 Last modification. import java.util.* ; class CurrencyConverterKL { public static void main( String[] not_in_use ) { Scanner keyboard = new Scanner( System.in ) ; System.out.print( "\n Type D to convert Dollars to Yen, or" + "\n type Y to convert Yen to Dollars! " ) ; char currency_selection = keyboard.nextLine().charAt( 0 ) ; double amount_of_yen, amount_of_dollars ; // On October 28, 2004, you needed 106.61 Yen to buy // one U.S. dollar. double exchange_rate = 106.61 ; if ( ( currency_selection == 'D' ) || ( currency_selection == 'd' ) ) { System.out.print( "\n Give dollar amount to convert: " ) ; amount_of_dollars = keyboard.nextDouble( ) ; amount_of_yen = exchange_rate * amount_of_dollars ; System.out.print( "\n " + amount_of_dollars + " U.S. dollars is " + amount_of_yen + " Japanese yen\n" ) ; } else if ( ( currency_selection == 'Y' ) || ( currency_selection == 'y' ) ) { System.out.print( "\n Give yen amount to convert: " ) ; amount_of_yen = keyboard.nextDouble( ) ; amount_of_dollars = amount_of_yen / exchange_rate ; System.out.print( "\n " + amount_of_yen + " Japanese yen is " + amount_of_dollars + " U.S. dollars\n" ) ; } else { System.out.print( "\n I do not understand \"" + currency_selection + "\".\n" ) ; } } }