Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

2. Set the variable, $count , to 108. Create a WHILE loop that displays numbers

ID: 3550570 • Letter: 2

Question

2.Set the variable,$count, to 108. Create a WHILE loop that displays numbers 108-130. Within this loop                    use an if-else statement to display 119 as "One Hundred Nineteen". All numbers should be on one line. Use any separator you wish, but at                    least a space for readability.                 

3.Create a simple FOR loop that displays the phrase "My Lucky Numbers are: " followed by the number range 108                    to 133. (Be careful to only display the phrase once, followed by the range of numbers!)                 

4.Create an array that will eventually output both the following keys and values: "New House                    Purchase"=>325000, "Monthly Payments"=>1875, "Should we buy?"=>"YES!"                 

5.Next, create a FOREACH loop that will output these values. (HINT: you will need to include an if-else                    statement that tests the value for integer).                 

6.Here is a sample of what                    your output should look like.                 

                    While Loop:
                    108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, One Hundred Nineteen, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130,

                    For Loop:
                    My Lucky Numbers are: 108 / 109 / 110 / 111 / 112 / 113 / 114 / 115 / 116 / 117 / 118 / 119 / 120 / 121 / 122 / 123 / 124 / 125 / 126 / 127 / 128 / 129 / 130 /                    131 / 132 / 133 /

                    Foreach Loop:
                    New House Purchase: $325000
                    Monthly Payments: $1875
                    Should we buy?: YES!                 

Explanation / Answer

I have puts lot off efforts for your Problem. Its working as your required outputs


<?php
// your First Assignment
echo "While Loop:<br/>";
$count=108;
while($count<=130)
{
    if($count==119)
    {
        echo " One Hundred Nineteen";
    }
    else
    {
        echo " ".$count;
   
   
    }
    $count++;
}
//your Second Assignment
echo "<br/><br/>For Loop:<br/>";
echo " My Lucky Numbers are:";
for($i=108;$i<=133;$i++)
{
     echo " ".$i;


}

//your Third Assignment is
echo "<br/><br/>Foreach Loop:";
$house=array("New House Puchase"=>"325000","Monthly Payments"=>1875,"Should we buy?"=>"YES!");

foreach($house as $key=>$value) //for each loop
{
       echo "<br />".$key." ".$value;
      

}

?>


Output::

While Loop:
108 109 110 111 112 113 114 115 116 117 118 One Hundred Nineteen 120 121 122 123 124 125 126 127 128 129 130

For Loop:
My Lucky Numbers are: 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133

Foreach Loop:
New House Puchase 325000
Monthly Payments 1875
Should we buy? YES!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote