Difference between revisions of "Humidex"
From CompSciWiki
Line 15: | Line 15: | ||
|SolutionCode= | |SolutionCode= | ||
− | + | import java.util.Scanner; | |
+ | |||
+ | public class A1Q2 { | ||
+ | public static void main (String[] args) { | ||
+ | //variables | ||
+ | double e; | ||
+ | double h; | ||
+ | double humidex; | ||
+ | |||
+ | //get input | ||
+ | Scanner keyboard = new Scanner(System.in); | ||
+ | System.out.println("Enter the dewpoint (in Celsius)"); | ||
+ | double D = keyboard.nextDouble(); | ||
+ | System.out.println("Enter the air temperature (in Celsius)"); | ||
+ | double T = keyboard.nextDouble(); | ||
+ | |||
+ | //e = 6.11 * Math.exp( 5417.77530 * ( 1 / 273.16 - 1/( 273.16 + D))); | ||
+ | e = 6.11 * Math.pow(Math.E,5417.77530 * ( 1 / 273.16 - 1/( 273.16 + D))); | ||
+ | h = 0.5555 * (e - 10); | ||
+ | |||
+ | //use Math.round | ||
+ | humidex = Math.round( (T + h)*10.0)/10.0; | ||
+ | |||
+ | System.out.println ("The humidex is " + humidex); | ||
+ | |||
+ | } | ||
+ | } | ||
|SideSectionTitle=Humidex | |SideSectionTitle=Humidex | ||
|SideSection= | |SideSection= |
Revision as of 12:30, 24 March 2011
Back to the Case Studies homepage
ProblemEnter Problem Here Pre tags, use a good program standards and programing line SHORT~!! Insert code here |
Humidex | |
---|---|---|
SolutionSolution for the answer | ||
Code |