This program will solve the classic "FizzBuzz" problem posed in many programing interviews. The idea is to examine all the numbers between start and stop. If the number is divisible by 3, then print "Fizz." If the number is divisible by 5 then print "Buzz." If it is divisible by both then print "FizzBuzz." Otherwise, just print the number. Start 27 Stop 45 Submit O Cancel FizzBuzz between 27 and 45 • Fizz • 28 • 29 • FizzBuzz 31 • 32 • Fizz • 34 • Buzz • Fizz 37 • 38 • Fizz • Buzz • 41 • Fizz • 43 • 44 • FizzBuzz

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

USING PHP

Write a solution to the “FizzBuzz” problem. The FizzBuzz problem is a classic programming interview problem in which a range of numbers is examined to locate those numbers divisible by 3 and 5. If the number is divisible by 3, then print "Fizz." If the number is divisible by 5 then print "Buzz." If it is divisible by both, then print "FizzBuzz." Otherwise, just print the number.

You should have an index.html(index.php) file. The index.html (index.php) has a form that submits data to the itself. You may optionally have a style file as well, referenced from both. If the user does not submit a start and stop number for the range (inclusive), then assume that start is 1 and stop is 100. Otherwise, use the specified range.

You may use either GET or POST for your form processing. Screen shots of one sample solution are given. You should try to get your solution to look as close to this output as possible.

 
<div class="col">
<label for="start">Enter a number between 1 and 50</label>
<input type="number" class="form-control" id="number" name="number" placeholder="Enter a number between 1 and 50" required value="<?php echo (safeParam($_REQUEST,
</div>
</div>|
</div>
<div class="form-group">
<div class="form-row mt-4 float-right">
<div class="btn-toolbar align-middle">
<button type="submit" class="btn btn-primary mr-1 d-flex justify-content-center align-content-between"><span class="material-icons">send</span>&nbsp;Submit</buttor
<button class="btn btn-secondary mr-1 d-flex justify-content-center align-content-between" onclick="get('index.php')"><span class="material-icons">cancel</span>&nl
</div>
</div>
</div>
</form>
</div>
</div>
</div>
"div>
liv class="row mt-4">
<div class="col-lg-12">
<h3>Here's some output from the form.</h3>
<?php
$number = safeParam ($_REQUEST, 'number', '10');
$number = max (min($number, 50), 1);
echo "<p>The number is {$number}. So here are ${number} lines of output:</p>\n<ul>\n";
for ($i = 0; $i < $number; ++$i) {
echo "
<li> This line $i </li>\n";
echo "</ul>";
?>
</div>
Transcribed Image Text:<div class="col"> <label for="start">Enter a number between 1 and 50</label> <input type="number" class="form-control" id="number" name="number" placeholder="Enter a number between 1 and 50" required value="<?php echo (safeParam($_REQUEST, </div> </div>| </div> <div class="form-group"> <div class="form-row mt-4 float-right"> <div class="btn-toolbar align-middle"> <button type="submit" class="btn btn-primary mr-1 d-flex justify-content-center align-content-between"><span class="material-icons">send</span>&nbsp;Submit</buttor <button class="btn btn-secondary mr-1 d-flex justify-content-center align-content-between" onclick="get('index.php')"><span class="material-icons">cancel</span>&nl </div> </div> </div> </form> </div> </div> </div> "div> liv class="row mt-4"> <div class="col-lg-12"> <h3>Here's some output from the form.</h3> <?php $number = safeParam ($_REQUEST, 'number', '10'); $number = max (min($number, 50), 1); echo "<p>The number is {$number}. So here are ${number} lines of output:</p>\n<ul>\n"; for ($i = 0; $i < $number; ++$i) { echo " <li> This line $i </li>\n"; echo "</ul>"; ?> </div>
This program will solve the classic "FizzBuz" problem posed in many programing interviews. The
idea is to examine all the numbers between start and stop. If the number is divisible by 3, then
print "Fizz." If the number is divisible by 5 then print "Buzz." If it is divisible by both then print
"FizzBuzz." Otherwise, just print the number.
Start
27
Stop
45
Submit
O Cancel
FizzBuzz between 27 and 45
• Fizz
28
• 29
FizzBuzz
• 31
• 32
Fizz
• 34
• Buzz
Fizz
• 37
38
• Fizz
Buzz
• 41
Fizz
43
• 44
• FizzBuzz
Transcribed Image Text:This program will solve the classic "FizzBuz" problem posed in many programing interviews. The idea is to examine all the numbers between start and stop. If the number is divisible by 3, then print "Fizz." If the number is divisible by 5 then print "Buzz." If it is divisible by both then print "FizzBuzz." Otherwise, just print the number. Start 27 Stop 45 Submit O Cancel FizzBuzz between 27 and 45 • Fizz 28 • 29 FizzBuzz • 31 • 32 Fizz • 34 • Buzz Fizz • 37 38 • Fizz Buzz • 41 Fizz 43 • 44 • FizzBuzz
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 6 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY