Write a program that allows each employee to enter the temperature at noon of ea
ID: 3555550 • Letter: W
Question
Write a program that allows each employee to enter the temperature at noon of each of the five days and displays the highest, lowest, and average (mean) temps. Write javascript that accepts five daily temperature readings and displays the highest, lowest, and average (mean) temperature. Use a For loop to the five readings. (Hint: Initialize the highest and lowest temperature variable to the firest temperature that's read, and then compare other temperature to see whether they are higher or lower.) Using parseFloat() method, convert the temp input into a decimal number and display this avg. to one decimal place.
Explanation / Answer
i have a program to find highest and lowest...
<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Calculate the sum, the product,the average and find smallest and largest number.</title>
<script type = "text/javascript">
<!--
var counter, //number of numbers entered by users
value, //the number entered by user
number, //number value
total, //the sum of the numbers
average, //the average of the numbers
product, //the product of the numbers
lowNumber, //the smallest number entered
highNumber; //the largest number entered
//Initialization phase
total =0; //clear total
product =1; //product
counter =0; //prepare to loop
//Processing phase
//prompt for imput and read number entered by user
value = window.prompt(
"Enter Integer Value, -1 to Quit:", "0");
//convert value string to an integer
number = parseInt( value );
while ( number != -1 ) {
// add number to total
total += number;
//calculate the product
product *= number;
//add 1 to counter
counter+= 1;
//prompt for input and read number entered by user
value = window.prompt(
"Enter Integer Value, -1 to Quit:", "0");
//convert value string to an integer
number = parseInt( value );
}
//Termination phase
if ( counter != 0 ) {
total = total; //calculate the sum
average = total / counter; //calculate the average
product = product; //calculate the product
lowNumber = number; //finds lowest number
//display sum of numbers
document.writeln(
"Sum is: " + total + "<br>Average is: " + average
+ "<br>Product is: " + product + "<br>low number is: " + lowNumber);
}
else
document.writeln( "<p>No numbers were entered</p>" );
// -->
</script>
</head>
<body>
<p>Click Refresh (or Reload) to run the script again<p>
</body>
</html>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.