Wind speed often is measured in kilometer per hours (km/h) or knots (nautic mile
ID: 3563899 • Letter: W
Question
Wind speed often is measured in kilometer per hours (km/h) or knots (nautic miles). Another measure is the Beaufort scale consisting of integer numbers from 1 to 12. Design and implement a Java class, for creating wind speeds. Implement a constructor to create wind speed for a given velocity in kilometers per hour.(2pts) The class must contain methods for getting the speed as knots or on the Beaufort scale. Furthermore, it must be possible to check whether the wind is calm or a European windstorm (Orcan). (4pts) Wind speeds less than 2 km/h are calm. More than 120 km/h is a European windstorm. A nautic mile is 1,852 Kilometer. The Beaufort scale is defined by B = (v/3.01)2/3, with v as the wind velocity in km/h. The Beaufort value B is rounded to the nearest integer. There are no Beaufort values larger than 12. Write a class WindSpeedTester that takes wind speed as from user. Creates a WindSpeed object and sets the value of windSpeed through constructor. Prints the different windstorm speeds by calling the methods of WinfStorm class.(4pts) Hint: You can calculate ab with Math.pow(a,b). The skeleton for
WindSpeed.java file is provided.
Explanation / Answer
public class WindSpeedTest { public static void main (String[] args) { WindSpeed = new WindSpeed (inputInt ("Enter a wind speed value: ")); } public static int doBeafourt (int WindSpeed) { int result = Math.pow((WindSpeed/3.01),(3/2)); System.out.println(); return result; } /* * Jets method for inputing a String */ public static String input(String prompt) { String inputLine = ""; System.out.print(prompt); try { inputLine = (new java.io.BufferedReader(new java.io.InputStreamReader(System.in))).readLine(); } catch (Exception e) { String err = e.toString(); System.out.println(err); inputLine=""; } return inputLine; } /* * Gest an integer input from the User. * @param prompt - the promt to show the User. */ public static int inputInt(String prompt) { String input = input(prompt); int inputInt; try{ inputInt = Integer.valueOf(input).intValue(); } catch (Exception e) { System.out.println("ERROR"); inputInt = -1; } return inputInt; } }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.