rei Posted April 30, 2008 Report Posted April 30, 2008 ok i got Double temp temp = (input - 32.0) * 5/9; i want its answer to show for example i keyed input=64 the answer is 17.77777778 how do i do the java to make it show the answer rounds off to become example 17.8?? :wacko: import javax.swing.JOptionPane; public class TempConversion{ public static void main (String args [] ) { String inputString, outputMessage, welcomeMessage; Double input,temperature,temp ; welcomeMessage = "Welcome to the temperature conversion program."; inputString = JOptionPane.showInputDialog(welcomeMessage + "\n" + "\n" + "\n" + "Enter the temperature in Fahrenheight degrees to the nearest degree."); input =Double.parseDouble( inputString ); temp = (input - 32) * 5/9; outputMessage = "The Fahrenheit temperature of " + input + "equals a Celsius temperature of" + temp; JOptionPane.showMessageDialog( null, outputMessage ) ; System.exit(0); }//main }//class
rei Posted May 1, 2008 Author Report Posted May 1, 2008 import javax.swing.JOptionPane; public class TempConversion{ public static void main (String args [] ) { String inputString, outputMessage, welcomeMessage; Double input,temperature,temp ; welcomeMessage = "Welcome to the temperature conversion program."; inputString = JOptionPane.showInputDialog(welcomeMessage + "\n" + "\n" + "\n" + "Enter the temperature in Fahrenheight degrees to the nearest degree."); input =Double.parseDouble( inputString ); temp = (input - 32) * 5/9; outputMessage = "The Fahrenheit temperature of " + input + "equals a Celsius temperature of" + temp; JOptionPane.showMessageDialog( null, outputMessage ) ; System.exit(0); }//main }//class