You are on page 1of 6

1.

Develop a java application to implement currency converter (Dollar to INR, yen


to INR, euro to INR and vice versa),distance converter(meter to km, miles to km
viceversa) time converter(hours to min, sec and viceversa) using packages.
package converters;
import java.io.*;
public class currency
{
int type;
double DOLLAR, YEN, EURO, INR ;
     double Val;
     Scanner s = new Scanner(System.in);
     public void fnRead()
     {
          System.out.println(“Enter type of Denomination : “);
          System.out.println(“1 : DOLLAR”);
          System.out.println(“2 : EURO”);
          System.out.println(“3 : YEN”);
          System.out.println(“4 : INR”);
          System.out.print(“Enter option : “);
          type = Integer.parseInt(s.nextLine().trim());
          System.out.print(“Enter number of denominations to be
converted : “);
          Val = Double.parseDouble(s.nextLine().trim());
     }
     public void fnConvert()
     {
          System.out.println(“Currency conversion : “);
          switch(type)
          {
              case 1:    INR = Val * 68.84;
                             System.out.println(“Dollar = “+Val);
                             System.out.println(“INR = “+INR);
                             break;
              case 2:    INR = Val * 80.90;
                         System.out.println(“EURO = “+Val);
                         System.out.println(“INR = “+INR);
                         break;
              case 3:    INR = Val * 0.62;
                             System.out.println(“YEN = “+Val);
                             System.out.println(“INR = “+INR);
                             break;
              case 4:    DOLLAR = Val / 68.84;
                             EURO = Val / 80.90;
                             YEN = Val / 0.62;
                             System.out.println(“INR = “+Val);
                             System.out.println(“Dollar = “+DOLLAR);
                             System.out.println(“EURO = “+EURO);
                             System.out.println(“YEN = “+YEN);
                             break;
          }
     }
}

// distance.java
package converters;
importjava.util.*;
public class distance
{
     int type;
     double METER, KM, MILES ;
     double Val;
     Scanner s = new Scanner(System.in);
     public void fnRead()
     {
          System.out.println(“Enter type : “);
          System.out.println(“1 : METER”);
          System.out.println(“2 : MILES”);
          System.out.println(“3 : KM”);
          System.out.print(“Enter option : “);
          type = Integer.parseInt(s.nextLine().trim());
          System.out.print(“Enter Value to be converted : “);
          Val = Double.parseDouble(s.nextLine().trim());
     }
     public void fnConvert()
     {
          System.out.println(“Distance conversion : “);
          switch(type)
          {
              case 1:    KM = Val / 1000;
                             System.out.println(“METER = ” + Val);
                             System.out.println(“KM = ” + KM);
                             break;
              case 2:    KM = Val / 0.621371;
                             System.out.println(“MILES = “+Val);
                             System.out.println(“KM = “+KM);
                             break;
              case 3:    METER = Val * 1000;
                             MILES = Val * 0.621371;
                             System.out.println(“KM = “+Val);
                             System.out.println(“METER = “+METER);
                             System.out.println(“MILES = “+MILES);
                             break;
          }
     }
}

// time.java
package converters;
import java.io.*;
importjava.util.*;
public class time
{
  int type;
int HR, MIN, SEC ;
int Val;
Scanner s = new Scanner(System.in);
public void fnRead()
{
System.out.println(“INPUT TYPE : “);
System.out.println(“1 : SECONDS”);
System.out.println(“2 : MINUTES”);
System.out.println(“3 : HOURS”);
System.out.print(“Enter option : “);
type = Integer.parseInt(s.nextLine().trim());
System.out.print(“Enter value : “);
Val = Integer.parseInt(s.nextLine().trim());
public void fnConvert()
{
System.out.println(“Time conversion : “);
switch(type)
{       
case 1:    MIN = (Val / 60) % 60;
  HR = Val / 3600;
  SEC = Val % 60;
System.out.println(Val + ” Seconds = ” + HR + ” hours, “+ MIN +” minutes and ” + SEC +”
seconds”);
break;
case 2:    HR = Val / 60;
MIN = Val % 60;
SEC = Val * 60;
System.out.println(Val + ” Minutes = ” + HR + ” hours and “+ MIN +” minutes”);
System.out.println(Val + ” Minutes = ” + SEC +” Seconds”);
break;
case 3:  HR = Val;
MIN = Val * 60;
SEC = MIN * 60;
System.out.println(HR + ” Hours = “+MIN + ” Minutes”);
  System.out.println(HR + ” Hours = “+SEC + ” Seconds”);
public class time
{
int type;
int HR, MIN, SEC ;
     int Val;
     Scanner s = new Scanner(System.in);
     public void fnRead()
     {
          System.out.println(“INPUT TYPE : “);
System.out.println(“1 : SECONDS”);
          System.out.println(“2 : MINUTES”);
          System.out.println(“3 : HOURS”);
System.out.print(“Enter option : “);
          type = Integer.parseInt(s.nextLine().trim());
          System.out.print(“Enter value : “);
          Val = Integer.parseInt(s.nextLine().trim());
     }
     public void fnConvert()
     {
          System.out.println(“Time conversion : “);
          switch(type)
          {
              case 1:MIN = (Val / 60) % 60;
                        HR = Val / 3600;
                        SEC = Val % 60;
                        System.out.println(Val + ” Seconds = ” + HR + ” hours, “+ MIN +” minutes and ”
+ SEC +” seconds”);
                        break;
              case 2:    HR = Val / 60;
                        MIN = Val % 60;
                        SEC = Val * 60;
                   System.out.println(Val + ” Minutes = ” + HR + ” hours and “+ MIN +” minutes”);
                        System.out.println(Val + ” Minutes = ” + SEC +” Seconds”);
                        break;
              case 3:    HR = Val;
                        MIN = Val * 60;
                        SEC = MIN * 60;
                        System.out.println(HR + ” Hours = “+MIN + ” Minutes”);
                        System.out.println(HR + ” Hours = “+SEC + ” Seconds”);
                        break;
          }
     }
}
// Conversion.java
import java.io.*;
importjava.util.*;
import converters.*;
class Conversion
{
     public static void main(String as[])
     {
          currency c1 = new currency();
          c1.fnRead();
          c1.fnConvert();
          distance d1 = new distance();
          d1.fnRead();
          d1.fnConvert();
          time t1 = new time();
          t1.fnRead();
          t1.fnConvert();
     }
}

You might also like