Wednesday, December 21, 2011

Java program to convert weight in kg to lb oz and drams


import java.util.*;

public class Ch1Q36x
{
 public static void main(String[] args)
  {Scanner kbd = new Scanner(System.in);
  System.out.print("Enter wt in Kg: ");
  double kg = kbd.nextDouble();
  double lb = kg*2.20462;
  double oz = lb%1*16;
  double dr = oz%1*16;
  System.out.println((int)lb + " lbs " +
                 (int)oz + " Oz and " +
                 dr + " drams");
    }
}

No comments:

Post a Comment