CST8238 – Lab 6 – Logical and Conditional (Solution)

$ 20.99
Category:

Description

Statements, 99 Bottles of Beer

Purpose

• 99 Bottles of Beer
• Upload your website to a Web server

• This lab must be handed in:
Assessment

• This Lab is worth 2% of your total course mark.
Estimated Time

• This Lab is estimated to take 2 hours.

This is only an estimate of the time required to complete this Lab. I would encourage you to work at your own pace and if at all possible obtain a laptop so that you can work on your assignments from anywhere

The following chapters of Fundamentals of Web Development will be useful in completing this exercise:

• Chapter 4
• Chapter 8
Lab Supplies

To complete this lab you will require the following lab supplies:

• Textbook: Fundamentals of Web Development by Randy Connolly and Ricardo Hoar
• EasyPHP, or other WAMP server
• Eclipse, Notepad (or other text editor, or IDE)
• FileZilla (or other FTP client)
Summary of Tasks

1. Develop the logic to display the song 99 Bottles of Beer
2. Develop the logic to order a random number of Bottles of Beer.
3. Upload your website to the webserver
4. View your webpage using a web browser
5. Submit Lab Link on Blackboard
6. Submit source code of all PHP files on Blackboard
Task 1

Before getting started with the following tasks, review the ‘Common Look and Feel’ video provided on Blackboard (under: Course Content → Extra Materials). Using the knowledge gained in these materials, implement the following Design Pattern to create a ‘Common Look and Feel’ to be used on every page of your website.

Your web site will include the following PHP scripts:
• Header.php
• Footer.php
• Menu.php
• All.php
• DivideByThree.php
• EvenOdd.php
• Random.php

Header.php
Header.php must contain a script to display a Common Header that will appear on every page. The header must contain a banner (images, css, etc).

Footer.php
Footer.php must contain a script to display a Common Footer that will appear on every page. The footer must contain Student Number, First Name, Last Name, Email Address

Menu.php
Menu.php must contain a script to display a Common Menu to be shown on every page. The menu must contain links to All.php, DivideByThree.php, EvenOdd.php, and Random.php

All.php
In All.php, you need to create a script that will display the lyrics to the song 99 Bottles of beer. To do this you must use the Logical and Conditional statements of PHP. Also use the PHP statement ‘include’ to add your Header, Menu and Footer to the page.

99 Bottles of Beer example:

99 bottles of beer on the wall…
99 bottles of beer…
You take one down you pass it around …
98 bottles of beer on the wall.

98 bottles of beer on the wall…
98 bottles of beer…
You take one down you pass it around …
97 bottles of beer on the wall.
. . . . …….
1 bottles of beer on the wall…
1 bottles of beer…
You take one down you pass it around …
0 bottles of beer on the wall.

There are no more bottles of beer.

DivideByThree.php
In DivideByThree.php, you need to create a script that will display modified lyrics to the song 99 Bottles of beer. You must implement it using the Logical and Conditional statements of PHP. Also use the PHP statement ‘include’ to add your Header, Menu and Footer to the page.

99 Bottles of Beer example:

99 bottles of beer is a multiple of 3…
98 bottles of beer is NOT a multiple of 3…
97 bottles of beer is NOT a multiple of 3…
96 bottles of beer is a multiple of 3…
………
……….
3 bottles of beer is a multiple of 3…
2 bottles of beer is NOT a multiple of 3…
1 bottles of beer is NOT a multiple of 3…

EvenOdd.php
In EvenOdd.php, you need to create a script that will display modified lyrics to the song 99 Bottles of beer. You must implement it using the Logical and Conditional statements of PHP. Also use the PHP statement ‘include’ to add your Header, Menu and Footer to the page.

99 Bottles of Beer example:

99 bottles of beer can serve odd number of guests.
You take 1 down from 99…
98 bottles of beer can serve even number of guests.

You take 2 down from 99…
97 bottles of beer can serve odd number of guests.

You take 3 down from 99…
96 bottles of beer can serve even number of guests.

You take 4 down from 99…
95 bottles of beer can serve odd number of guests.
………
……….
3 bottles of beer can serve odd number of guests.
You take 97 down from 99.

2 bottles of beer can serve even number of guests.
You take 98 down from 99.

1 bottles of beer can serve odd number of guests.
You take 99 down from 99.

0 bottles of beer on the wall.
There are no more bottles of beer.

Random.php
In Random.php, you need to create a script that will order/generate a random number of Bottles of Beer. You have to prompt the user for the range of numbers from which the Web server should generate a random number.

If the generated random number is even (e.g., 78), you have to display the following: “78 Bottles of Beer can serve even number of guests.”

If the generated random number is odd (e.g., 67), you have to display the following: “67 Bottles of Beer can serve odd number of guests.”

You must implement it using HTML form elements as well as the Logical and Conditional statements of PHP. Also use the PHP statement ‘include’ to add your Header, Menu and Footer to the page.

Hints for Random.php: The built-in function for generating a random number in PHP is: rand(Range1, Range2). Range 1 and Range 2 values must be accepted from the user prompt.
Note: Please make sure that the header, footer, and menu are distinguishable with respect to the body (main content) of the web page.
Task 2

Upload your website to the Web server. Use an FTP client to connect to your Web server.

Once you connect to the webserver using an FTP client, create a directory called
‘/CST8238/Lab6’. Once your course directory has been created navigate to that new directory. Add your index.php file to this location. (Using FileZilla simply drag the index.php file into your folder). The index.php file will refer to all of your php files.

We recommend the FTP client Filezilla. The program is provided for free (and open source for those who are interested in such things) by the Mozilla Foundation; the makers of Firefox and Thunderbird.

For more information on using FileZilla please navigate to the following material in Blackboard:
Course Content → Extra Material → FileZilla Guide (Video)
Task 3

View your website using a web browser. Open a web browser and navigate to the following web address:

http://web-server_domain_name/CST8238/Lab6/<filename>

For example, the web address to my page is:

http://profrejaul.com/CST8238/Lab6/index.php

Where ‘profrejaul.com’ is the domain name of the Web server, ‘ /CST8238/Lab6’ is the name of the directory I created in the Web server using FTP client and ‘index.php’ is the main web page I created for this lab.
Task 4

Once you have confirmed that you webpage is available online, you are ready to hand in your lab.

To hand in your lab go to Blackboard and navigate to Course Content → Labs and click on ‘Lab 6
– Logical and Conditional Statements, 99 Bottles of Beer’ link.

Under “Assignment Materials”, in the Submission text box write out the following Information:

• Student Number
• First Name
• Last Name
• The URL, or hyperlink, prepared in Task 3

Under “Assignment Submission”, submit (attach) source code of the following files:
• Header.php
• Footer.php
• Menu.php
• All.php
• DivideByThree.php
• EvenOdd.php
• Random.php

Finally, once the Submission and Comments section are complete, click the ‘Submit’ button to send the lab to your professor.

IMPORTANT NOTE: If the URL, or hyperlink, does not direct the professor to the lab you will receive a ZERO for the lab assignment.

Reviews

There are no reviews yet.

Be the first to review “CST8238 – Lab 6 – Logical and Conditional (Solution)”

Your email address will not be published. Required fields are marked *