Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Apr 8th, 2013  |  syntax: Java  |  size: 1.51 KB  |  views: 46  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import java.io.File;
  2.  
  3. import java.io.FileNotFoundException;
  4. import java.util.Scanner;
  5. public class WindChill {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner input = null;
  9.         try {
  10.             input = new Scanner(new File("WindChillData.txt"));
  11.         } catch (FileNotFoundException e) {
  12.             System.err.println("ERROR - File not found");
  13.             System.exit(1);
  14.         }        
  15.        
  16.         while (input.hasNextLine()) {
  17.             String text = input.nextLine();
  18.             calc(text);
  19.         }
  20.         }
  21.    
  22.          
  23.   public static void calc(String text){
  24.                 Scanner calcLine= new Scanner (text);
  25.        
  26.                
  27.                    double tempF;
  28.                    double velocityMPH;
  29.                double chillTemp;
  30.                
  31.                tempF = calcLine.nextDouble();
  32.                while ( tempF != -9999 )
  33.                {
  34.                    
  35.                    velocityMPH = calcLine.nextDouble();
  36.                    chillTemp = 35.74 + 0.6215*tempF - 35.75*Math.pow(velocityMPH, 0.16) + 0.4275*tempF*Math.pow(velocityMPH, 0.16);
  37.                    System.out.printf("The wind chill for temp (degrees F) =  %6.1f", tempF);
  38.                    System.out.printf(" and wind velocity (MPH) =  %6.1f", velocityMPH);
  39.                    System.out.printf(" is %6.1f", chillTemp);
  40.                    System.out.println(" Degrees Fahrenheit");
  41.                    
  42.                   // tempF = calcLine.nextDouble();
  43.                }
  44.            }
  45.        }