logo image

Java program to convert kilograms to grams

Following program shows you how to convert kilograms to grams. In this program we get kilograms from user, once we get those we need to multiply with 1000 so that we get in grams

import java.util.Scanner;

public class MathUnitConversions9 {

	public static void main(String[] args) {

		double kilograms;

		Scanner in = new Scanner(System.in);

		System.out.println("Please enter kilograms:");
		kilograms = in.nextDouble();

		double grams = kilograms * 1000;
		System.out.println(grams + " Grams");



Please enter kilograms:
5000.0 Grams