Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. import java.text.DecimalFormat;
  2.  
  3. import javax.swing.JOptionPane;
  4.  
  5. public class question2{
  6. public static void main(String[] args) {
  7. String tempString = JOptionPane.showInputDialog(null, "Enter the temperature in Fahrenheit degrees", "Input", JOptionPane.QUESTION_MESSAGE);
  8. int temp = Integer.parseInt(tempString);
  9.  
  10. String mphString = JOptionPane.showInputDialog(null, "Enter the wind speed mph", "Input", JOptionPane.QUESTION_MESSAGE);
  11.  
  12. int mph = Integer.parseInt(mphString);
  13. double twc=35.74+0.6215*temp-35.75*Math.pow(mph,0.16)+0.4275*Math.pow(mph,0.16)*temp;
  14. DecimalFormat f2 = new DecimalFormat("##.#");
  15.  
  16.  
  17. //display wind chill in a message dialog box
  18. JOptionPane.showMessageDialog(null, f2, "The wind chill is “+f2.format(twc), JOptionPane.INFORMATION_MESSAGE);
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement