Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.util.Scanner;
- public class WindChill {
- public static void main(String[] args) {
- Scanner input = null;
- try {
- input = new Scanner(new File("WindChillData.txt"));
- } catch (FileNotFoundException e) {
- System.err.println("ERROR - File not found");
- System.exit(1);
- }
- while (input.hasNextLine()) {
- String text = input.nextLine();
- calc(text);
- }
- }
- public static void calc(String text){
- Scanner calcLine= new Scanner (text);
- double tempF;
- double velocityMPH;
- double chillTemp;
- tempF = calcLine.nextDouble();
- while ( tempF != -9999 )
- {
- velocityMPH = calcLine.nextDouble();
- chillTemp = 35.74 + 0.6215*tempF - 35.75*Math.pow(velocityMPH, 0.16) + 0.4275*tempF*Math.pow(velocityMPH, 0.16);
- System.out.printf("The wind chill for temp (degrees F) = %6.1f", tempF);
- System.out.printf(" and wind velocity (MPH) = %6.1f", velocityMPH);
- System.out.printf(" is %6.1f", chillTemp);
- System.out.println(" Degrees Fahrenheit");
- // tempF = calcLine.nextDouble();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement