Question
// INSTRUCTIONS: p4-whileLoop p4-while Loop Numbers: Sum: Average: Min: Max: Type your name here
// INSTRUCTIONS:
// Turn on error reporting.
error_reporting(E_ALL);
ini_set('display_errors', '1');
// Randomly generated count.
$count = rand(1, 30);
$year = 2021;
$sum = 0;
$ave = 0.0;
$min = 0;
$max = 0;
$numbers = "";
//while construct
// #1 -- Write a while statement that generates $count random numbers in the closed range [-50, 50].
//To generate a random number in a range use the rand() function as in $count = rand(-50, 50);.
//Each time the body of the while executes, perform the following computations in the listed order:
//build the $numbers string so it contains each randomly generated number. Each number should have a leading space, e.g. 4 -50 4.
//Add the random number to the running sum.
//Check if the random number is the smallest thus far and update $min if need be.
//Check if the random number is the largest thus far and update $max if need be.
//TYPE YOUR CODE HERE
// #2 -- After the while loop finishes, compute the average and update $ave.
//TYPE YOUR CODE HERE
?>
p4-while Loop
© Type your name here
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started