Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 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. while(Repeat!=0);
  8. String tempString = JOptionPane.showInputDialog(null, "Enter the temperature in Fahrenheit degrees", "Input", JOptionPane.QUESTION_MESSAGE);
  9. int temp = Integer.parseInt(tempString);
  10. //Confirms the temperature is within range
  11. if ((temp>41)||(temp<-58)) {
  12. JOptionPane.showMessageDialog(null,"The temperature must be between -58 and 41F°");
  13. int Repeat=1;
  14. }
  15. String mphString = JOptionPane.showInputDialog(null, "Enter the wind speed in mph", "Input", JOptionPane.QUESTION_MESSAGE);
  16.  
  17. int mph = Integer.parseInt(mphString);
  18. if (mph<2){
  19. JOptionPane.showMessageDialog(null,"The wind speed must be higher than 2 mph.");
  20. }
  21. //The actual equation.
  22. double twc=35.74+0.6215*temp-35.75*Math.pow(mph,0.16)+0.4275*Math.pow(mph,0.16)*temp;
  23. DecimalFormat f2 = new DecimalFormat("##.#F°");
  24.  
  25.  
  26. //This will display wind chill in a message dialog box.
  27. JOptionPane.showMessageDialog(null,"The wind chill is " +f2.format(twc),"Message", JOptionPane.INFORMATION_MESSAGE);
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement