Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class WindChillTable {
- public static void drawHorizontalLine() {
- for (int i=0; i<49; i++) {
- System.out.print("-");
- } // for
- System.out.println(); // new line
- } // drawHorizontalLine()
- public static int getWindChill(int t, int ws) {
- double wc;
- wc = 91.4 - (0.474677 - 0.020425 * ws + 0.303107 * Math.sqrt(ws)) * (91.4 - t);
- return (int) wc;
- } // getWindChill()
- public static void main(String[] args) {
- System.out.println ("Temperature (degrees F)");
- drawHorizontalLine();
- System.out.print(" "); // 6 spaces for alignment
- for (int temp=50; temp>=-50; temp-=10) {
- System.out.printf("%4d",temp);
- } // for
- System.out.println(); // new line
- drawHorizontalLine();
- System.out.println("WS Equivalent Temperature (degrees F)");
- System.out.println("MPH (Equivalent in cooling power on exposed flesh under calm conditions)");
- drawHorizontalLine();
- for (int windSpeed=5; windSpeed<=50; windSpeed+=5) {
- System.out.printf("%3d | ",windSpeed);
- for (int temp=50; temp>=-50; temp-=10) {
- System.out.printf("%4d", getWindChill(temp, windSpeed));
- } // for t
- System.out.println(); // new line
- } // for windSpeed
- } // main()
- } // class WindChillTable
Advertisement
Add Comment
Please, Sign In to add comment