/** * Weight Calculator > BufferedReaderInput.java * * Displays a table of calculated weights on Jupiter using the console * for both input and output. * * @author Dale Reed */ import java.io.*; // used for Buffered Reader console input public class BufferedReaderInput { public static void main(String[] args) throws IOException { // variable declarations double earthWeight = 100.0; // weight on the earth, declared and initialized double weightMultiplier = 2.628099173553719; // factor for finding Jupiter weight given earth's // create the buffered reader BufferedReader reader = new BufferedReader( new InputStreamReader(System.in) ); // Prompt for and get the weight on earth, using console input System.out.print( "Enter your weight on earth: " ); String userInput = reader.readLine(); // Now convert the input string into a numerical value earthWeight = Double.parseDouble( userInput); // display weight on Jupiter double jupiterWeight = earthWeight * weightMultiplier; System.out.print( "If on earth you weigh " + earthWeight + ", "); System.out.println( "then on Jupiter you weigh " + jupiterWeight ); } } /* Output: Enter your weight on earth: 220 If on earth you weigh 220.0, then on Jupiter you weigh 578.1818181818182 */