Calculator.java 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. public class Calculator {
  2. public Calculator(){
  3. }
  4. // Luchtdruk in hPa
  5. // Malek&Tom
  6. public double luchtdruk(short mval)
  7. {
  8. double luchtdruk = (mval / 1000f) * 33.86389;
  9. return luchtdruk;
  10. }
  11. // Temperatuur in graden Celcius
  12. // Malek&Tom
  13. public double temperatuur(short mval)
  14. {
  15. double temperatuur = (((double)mval / 10) -32) / 1.8;
  16. return temperatuur;
  17. }
  18. // Relatieve luchtvochtigheid in %
  19. // Malek&Tom
  20. public double luchtVochtigheid(short mval)
  21. {
  22. double luchtvochtigheid = mval;
  23. return luchtvochtigheid;
  24. }
  25. // Windsnelheid in m/s
  26. // Janco&Tim
  27. public double windSnelheid(short mval)
  28. {
  29. double windSpeed = mval * 0.44704;
  30. return windSpeed;
  31. }
  32. // Windrichting in noord, oost, zuid en west.
  33. // Kenneth&Daniël
  34. public String windRichting(short mval)
  35. {
  36. String direction = "Error";
  37. if(mval < 12)
  38. {
  39. direction = "N";
  40. }
  41. else if(mval < 34)
  42. {
  43. direction = "NNO";
  44. }
  45. else if(mval < 57)
  46. {
  47. direction = "NO";
  48. }
  49. else if(mval < 79)
  50. {
  51. direction = "ONO";
  52. }
  53. else if(mval < 102)
  54. {
  55. direction = "O";
  56. }
  57. else if(mval < 124)
  58. {
  59. direction = "OZO";
  60. }
  61. else if(mval < 147)
  62. {
  63. direction = "ZO";
  64. }
  65. else if(mval < 169)
  66. {
  67. direction = "ZZO";
  68. }
  69. else if(mval < 192)
  70. {
  71. direction = "Z";
  72. }
  73. else if(mval < 214)
  74. {
  75. direction = "ZZW";
  76. }
  77. else if(mval < 237)
  78. {
  79. direction = "ZW";
  80. }
  81. else if(mval < 259)
  82. {
  83. direction = "WZW";
  84. }
  85. else if(mval < 282)
  86. {
  87. direction = "W";
  88. }
  89. else if(mval < 304)
  90. {
  91. direction = "WNW";
  92. }
  93. else if(mval < 327)
  94. {
  95. direction = "NW";
  96. }
  97. else if(mval < 349)
  98. {
  99. direction = "NNW";
  100. }
  101. else if(mval < 360)
  102. {
  103. direction = "N";
  104. }
  105. return direction;
  106. }
  107. // Regenmeter in mm
  108. // Kenneth&Daniël
  109. public double regenmeter(short mval)
  110. {
  111. double rainAmount = (double)mval*0.2;
  112. return rainAmount;
  113. }
  114. // uvIndex in index
  115. // Kenneth&Daniël
  116. public double uvIndex(short mval)
  117. {
  118. double index = (double) mval/10;
  119. return index;
  120. }
  121. // BatterySpanning in Volt
  122. // Janco&Tim
  123. public double batterySpanning(short mval){
  124. double voltage = (((double)mval * 300)/512)/100;
  125. return voltage;
  126. }
  127. // sunRise en Sunset in tijdformaat hh:mm
  128. // Janco&Tim
  129. public String sunRise(short mval){
  130. return sun(mval);
  131. }
  132. public String sunSet(short mval){
  133. return sun(mval);
  134. }
  135. private String sun(short sunRaw){
  136. String tijd = "";
  137. for(int i = 0; i <= 3; i++){
  138. tijd = sunRaw % 10 + tijd;
  139. sunRaw /= 10;
  140. if(i == 1){
  141. tijd = ":" + tijd;
  142. }
  143. }
  144. return tijd;
  145. }
  146. //windchill in graden Celcius
  147. //Janco en Keneth
  148. public double windChill(short gradenFahrenheit, short mijlPerUur)
  149. {
  150. short windChill = (short) (35.74 + (0.6215*gradenFahrenheit) - 35.75*Math.pow(mijlPerUur, 0.16) + 0.4275*gradenFahrenheit*Math.pow(mijlPerUur, 0.16));
  151. return temperatuur(windChill);
  152. }
  153. //Heatindex in celcius
  154. //Tom met Malek
  155. public double heatIndex(double luchtv, double t)
  156. {
  157. double heatindex = -42.379 + (2.04901523 * t) + (10.14333127 * luchtv) - (0.22475541 * t * luchtv)
  158. - (6.83783 * Math.pow(10,-3) * Math.pow(t,2)) - (5.481717 * Math.pow(10,-2) * Math.pow(luchtv,2))
  159. + (1.22874 * Math.pow(10,-3) * Math.pow(t,2) * luchtv) + (8.5282 * Math.pow(10,-4) * t * Math.pow(luchtv,2))
  160. - (1.99 * Math.pow(10,-6) * Math.pow(t,2) * Math.pow(luchtv,2));
  161. return heatindex;
  162. }
  163. //Dauwpunt in Celcius
  164. //Daniel en Tim
  165. public double dewPoint(double omgevingsTemp, short luchtVochtigheid)
  166. {
  167. double hm = luchtVochtigheid/100f;
  168. double dauwpunt = Math.pow( hm, (1/8f)) * (112 + 0.9*omgevingsTemp) + (0.1*omgevingsTemp) - 112;
  169. return dauwpunt;
  170. }
  171. public double cloudHeight(double temp, short luchtVochtigheid ){
  172. double wolkhoogte = 125 * (temp-dewPoint(temp, luchtVochtigheid));
  173. return wolkhoogte;
  174. }
  175. public void opdrachtEenA(){
  176. for(int i = 0; i<4; i++){
  177. }
  178. }
  179. }