Skip to content

Instantly share code, notes, and snippets.

@spukles
Created September 21, 2022 17:43
Show Gist options
  • Save spukles/0a6839957be410ea2a7199fae95a3020 to your computer and use it in GitHub Desktop.
Save spukles/0a6839957be410ea2a7199fae95a3020 to your computer and use it in GitHub Desktop.
import java.util.Scanner;
public class lbstokg{
//Main Method
public static void main (String[] args){
//Declare variables
double pounds;
double kilograms;
//Create a scanner object
Scanner input = new Scanner (System.in);
//Recieve inputs from keyboard
System.out.println("Enter a number in pounds");
pounds = input.nextDouble();
//Compute kilograms
//one pound is 0.45359237
kilograms = pounds * 0.45359237;
//Display result
System.out.println(pounds + " is " + kilograms+ " kilograms ");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment