Professional Documents
Culture Documents
// 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();
}
}