import java.util.Scanner;
public class Conversion
{
public static void main(String[]args)
{
Scanner in=new Scanner (System.in);
System.out.println("Enter time in milliseconds");
double time=in.nextDouble();
String unit="ms";
if(time>=365*24*60*60*1000L)
{
unit="years";
time/=365*24*60*60*1000L;
}
else if(time>=24*60*60*1000)
{
unit="days";
time/=24*60*60*1000;
}
else if(time>=60*60*1000)
{
unit="hours";
time/=60*60*1000;
}
else if(time>=60*1000)
{
unit="minutes";
time/=60*1000;
}
else if(time>=1000)
{
unit="seconds";
time/=1000;
}
System.out.println("Most appropriate unit for this time is "+unit+" ");
System.out.println("This time is nearly equal to "+time+" "+unit);
}
}
public class Conversion
{
public static void main(String[]args)
{
Scanner in=new Scanner (System.in);
System.out.println("Enter time in milliseconds");
double time=in.nextDouble();
String unit="ms";
if(time>=365*24*60*60*1000L)
{
unit="years";
time/=365*24*60*60*1000L;
}
else if(time>=24*60*60*1000)
{
unit="days";
time/=24*60*60*1000;
}
else if(time>=60*60*1000)
{
unit="hours";
time/=60*60*1000;
}
else if(time>=60*1000)
{
unit="minutes";
time/=60*1000;
}
else if(time>=1000)
{
unit="seconds";
time/=1000;
}
System.out.println("Most appropriate unit for this time is "+unit+" ");
System.out.println("This time is nearly equal to "+time+" "+unit);
}
}
No comments:
Post a Comment