Jump to content
rei

java help plox

Recommended Posts

Posted

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

Posted

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



×
×
  • Create New...