Help writing program. The National Weather Service computes the windchill index
ID: 3697235 • Letter: H
Question
Help writing program. The National Weather Service computes the windchill index using the following formula: 35.74+0.6215T-35.75(V^0.16 )+0.4275T(V^0.16) Where T is the temperature in degrees Fahrenheit, and V is the wind speed in miles per hour. Write a program that prints a nicely formatted table of windchill values. Rows should represent wind speed for 0 to 50 in 5 mph increments, and the columns represent temperatures from -20 to +60 in 10-degree increments. Note: the formula only applies for wind speeds in excess of 3 miles per hour. Create a function named windChill that receives the temperature and wind speed as parameters. Create a decision structure that returns the wind chill (chill) if the wind chill is greater than 3. Otherwise it returns the temperature as chill if v > 3: chill = 35.74 + 0.6215*t - 35.75*(v**0.16) + 0.4275*t*(v**0.16) else: chill = t return chill Create the main function which displays the table of values. Print the table headings: Wind Chill Table then create two blank lines Temperature should be centered at 70 print(“Temperature”.center(70)) MPH with a separator | print(“MPH|”, end’ ‘) Create a list of temperatures with a range from -20 to 60 with step of 10. Print each of the temperatures Using a for loop, step through each value in temps for t in temps: print(“{0:5}”.format(t), end= ‘ ‘) Output on a new line three dashes and a plus sign followed by a series of 55 dashes Using a for loop, print the lines of the table Print the velocity with a range starting at 0 and ending at 50, with step of 5. – Use vel as the loop control variable. Using a for loop inside the outer loop, step through the temperatures in the temps list and output the windchilll. for temp in temps: print(“{0:5.0f}”.format(windChill(temp, vel)), end= ‘ ‘) print() Call main. PART 2: Heating and cooling degree-days are measures used by utility companies to estimate energy requirements. If the average temperature for a day is below 60, then the number of degrees below 60 is added to the heating degree-days. If the temperature is above 80, the amount over 80 is added to the cooling degree-days. Write a program that accepts a sequence of average daily temps and computes the running total of cooling and heating degree-days. The program should print these two totals after all the data has been processed. Within main, print your program description Set the heating and cooling variables to zero Input a value for the daily temperature as tempStr Use a while loop to test if the temperature entered is != “” Inside the loop: eval temperature variable as temp Calculate heating as heating + max(0, 60-temp) Calculate cooling as cooling + max(0, temp – 80) Get the next input value for the daily temperature as tempStr Outside the loop: Print heating degree-days Print cooling degree-days
Explanation / Answer
import java.util.Scanner; public class Tempratureprograme { public static void main(String[] args) { temperatures(); } public static void temperatures(){ double temperature; double biggest = 0; double smallest = 0; double totalNum = 0; double counter = 1; int numberAmount = 0; double average = totalNum/numberAmount; Scanner input = new Scanner(System.in); System.out.println("Please enter the temperature(s) - end the program with -100"); System.out.print("-> "); do { temperature = input.nextDouble(); numberAmount++; totalNum = totalNum + temperatur; System.out.print("-> "); if(temperature > max) { max=temperature; counter= 0; } if(temperatureRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.