└── currency converter.java /currency converter.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | public class currencyconv { 3 | //variable declaration 4 | public static double yen, dollar, euro, Y,D,E; 5 | //constructor 6 | currencyconv(){ 7 | Y = 0.57; 8 | D = 83; 9 | E = 91; 10 | } 11 | //method to convert yen,dollar,euro to indian rupee 12 | public static void toInr(double yen, double dollar, double euro){ 13 | double ry, rd, re; 14 | ry = yen*Y; 15 | rd = dollar*D; 16 | re = euro*E; 17 | System.out.println("Rupees equivalent of "+yen+" yen is Rs: "+ry); 18 | System.out.println("Rupees equivalent of "+dollar+" yen is Rs: "+rd); 19 | System.out.println("Rupees equivalent of "+euro+" yen is Rs: "+re); 20 | } 21 | //method to convert indian rupee to yen,dollar,euro 22 | public static void inrTo(double inr){ 23 | double y,d,e; 24 | y = inr/Y; 25 | d = inr/D; 26 | e = inr/E; 27 | System.out.println("Yen equivalent of "+inr+" inr is Yen: "+String.format("%.2f",y)); 28 | System.out.println("Dollar equivalent of "+inr+" inr is Dollar: "+String.format("%.2f",d)); 29 | System.out.println("Euro equivalent of "+inr+" inr is Euro: "+String.format("%.2f",e)); 30 | } 31 | //main class 32 | public static void main(String[] args){ 33 | //object and variable declaration 34 | Scanner sc = new Scanner(System.in); 35 | currencyconv c = new currencyconv(); 36 | double yen=0, dollar=0, euro=0, inr=0; 37 | 38 | // currency conversion method 1 39 | System.out.println("Currency conversion: Yen,Dollar,Euro to INR"); 40 | System.out.print("enter yen: "); 41 | yen = sc.nextDouble(); 42 | System.out.print("enter dollar: "); 43 | dollar = sc.nextDouble(); 44 | System.out.print("enter euro: "); 45 | euro = sc.nextDouble(); 46 | toInr(yen,dollar,euro); 47 | 48 | System.out.println("-----------------------------"); 49 | 50 | //currency conversion method 2 51 | System.out.println("Currency conversion: INR to Yen,Dollar,Euro"); 52 | System.out.print("enter inr: "); 53 | inr = sc.nextDouble(); 54 | inrTo(inr); 55 | } 56 | } 57 | --------------------------------------------------------------------------------