Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.text.DecimalFormat;
- import javax.swing.JOptionPane;
- public class question2{
- public static void main(String[] args) {
- String tempString = JOptionPane.showInputDialog(null, "Enter the temperature in Fahrenheit degrees", "Input", JOptionPane.QUESTION_MESSAGE);
- int temp = Integer.parseInt(tempString);
- String mphString = JOptionPane.showInputDialog(null, "Enter the wind speed mph", "Input", JOptionPane.QUESTION_MESSAGE);
- int mph = Integer.parseInt(mphString);
- double twc=35.74+0.6215*temp-35.75*Math.pow(mph,0.16)+0.4275*Math.pow(mph,0.16)*temp;
- DecimalFormat f2 = new DecimalFormat("##.#");
- //display wind chill in a message dialog box
- JOptionPane.showMessageDialog(null, f2, "The wind chill is “+f2.format(twc), JOptionPane.INFORMATION_MESSAGE);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement