- Wind chill.
Given the temperature t (in Fahrenheit) and the wind speed v (in miles per hour), the National Weather Service defines the effective temperature (the wind chill) to be:
Write a program WindChill_YI.java that takes two double command-line arguments t and v and prints the wind chill. Use Math.pow(a, b) to compute ab.
Note: the formula is not valid if t is larger than 50 in absolute value or if v is larger than 120 or less than 3 (you may assume that the values you get are in that range).
Resources for some of these assignments:
[spoiler title=’Math.random()’]/** * An itty bitty program to learn about Math.random() * GE * 9/28/2017 * */ public class MathRandTest_GE { public static void main(String []args) { for (int i = 0; i < 100; i++) { System.out.println(Math.random()); } } }[/spoiler] [spoiler title='Scanner Class']
/** * good resource: http://docs.oracle.com/javase/tutorial/essential/io/scanning.html * @author gracielaelia * Problem: Both hasNext and next methods may block waiting for further input. * hasNext() doesn't return false ever!!!! next() blocks until something is input! * As you're reading from stdin, that'll either be when you send an EOF character (usually ^d on Unix), * or at the end of the file if you use < style redirection. * You cannot easily send and EOF character using the keyboard" * -- usually Ctrl+D on Linux/Unix/Mac * or Ctrl+Z on Windows does it */ import java.util.Scanner; public class ScannerTest_GE{ public static void main(String [] args) { Scanner scan = new Scanner(System.in); String name; // just a declaration double base, exponent; System.out.println("Enter the base "); base = scan.nextDouble(); System.out.println("Enter the exponent "); exponent = scan.nextDouble(); System.out.println("Enter your name "); name = scan.next(); System.out.println(name + " the value is " + Math.pow(base,exponent)); System.out.println(name + " the integer value is " + (int)Math.pow(base,exponent)); } }[/spoiler]