All pastes #743899 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-10-20 21:38 UTC
rendered paste body
import java.io.*;
import java.util.*;
import javax.swing.JOptionPane;

public class lbstokg
	{
		public static void main(String[]args)
            {
		//Variables that are entered
		String poundstr;
		double pound;

		poundstr = JOptionPane.showInputDialog("Please enter weight in pounds (lbs):");
		pound = Double.parseDouble(poundstr);

		//Conversion 1lb = 2.2 kilograms
		double kilo = (pound/2.2);

		//How the answer is displayed on the window
		String answer = ("" + (int)pound + " lbs is " + String.format("%.1f",kilo) + " Kilograms");

		//Window properties
		JOptionPane.showMessageDialog(null,answer,"Conversion",
		JOptionPane.INFORMATION_MESSAGE);

		//IF click yes - then re-open original JOptionpane if cancel - exit out program
		int cancel = (JOptionPane.CANCEL_OPTION);
		int value =  (JOptionPane.OK_OPTION);
		if (value == JOptionPane.OK_OPTION) {
			JOptionPane.showInputDialog("Please enter weight in pounds (lbs):"); }

		if (cancel == JOptionPane.CANCEL_OPTION) {
		System.exit(0); }

		}

	}