Showing posts with label code academy. Show all posts
Showing posts with label code academy. Show all posts

Friday, April 25, 2014

Conditionals and Control Flow - 4/4 - codeacademy.com

Instructions:
  1. If your condition is true, your code should echo "The condition is true"
  2. Otherwise (else) when it is false, your code should echo "The condition is false".
  3. Make sure your condition evaluates tofalse, so that your program prints out "The condition is false".

<html>
  <head>
  </head>
  <body>
    <p>
      <?php
        $trueOrfalse = "true";// Write your if/elseif/else statement here!
        if ($yourName == "false") {
            echo "The condition is true";
        }
        else {
            echo "The condition is false";
        }
     
      ?>
    </p>
  </body>
</html>

Conditionals and Control Flow - 4/4 - codeacademy.com

Instructions:
  1. If your condition is true, your code should echo "The condition is true"
  2. Otherwise (else) when it is false, your code should echo "The condition is false".
  3. Make sure your condition evaluates tofalse, so that your program prints out "The condition is false".

<html>
  <head>
  </head>
  <body>
    <p>
      <?php
        $trueOrfalse = "true";// Write your if/elseif/else statement here!
        if ($yourName == "false") {
            echo "The condition is true";
        }
        else {
            echo "The condition is false";
        }
     
      ?>
    </p>
  </body>
</html>

Conditionals and Control Flow - 3/4 - codeacademy.com

Instructions:  Under your if statement on line 12, write an else statement to capture the people who are only buying 5 items or fewer. In their case, useecho to output "You get a 5% discount!"



<html>
  <head>
  </head>
  <body>
    <p>
      <?php
        $items = 3;
     
        if($items > 5) {
          echo "You get a 10% discount!";
        }
        else {
          echo "You get a 5% discount!"
     }
      ?>
    </p>
  </body>
</html>

Conditionals and Control Flow - 3/4 - codeacademy.com

Instructions:  Under your if statement on line 12, write an else statement to capture the people who are only buying 5 items or fewer. In their case, useecho to output "You get a 5% discount!"



<html>
  <head>
  </head>
  <body>
    <p>
      <?php
        $items = 3;
     
        if($items > 5) {
          echo "You get a 10% discount!";
        }
        else {
          echo "You get a 5% discount!"
     }
      ?>
    </p>
  </body>
</html>

Conditionals and Control Flow - 2/4 - codeacademy.com

Instructions:
  1. On line 7, set $items equal to a number greater than 5. Make sure to put a semicolon at the end of the line.
  2. On line 9, edit the condition so that your program will print out You get a10% discount!

<html>
  <head>
  </head>
  <body>
    <p>
      <?php
        $items = 6    // Set this to a number greater than 5!
     
        if($items > 5) {
          echo "You get a 10% discount!";
        }
      ?>
    </p>
  </body>
</html>

Conditionals and Control Flow - 2/4 - codeacademy.com

Instructions:
  1. On line 7, set $items equal to a number greater than 5. Make sure to put a semicolon at the end of the line.
  2. On line 9, edit the condition so that your program will print out You get a10% discount!

<html>
  <head>
  </head>
  <body>
    <p>
      <?php
        $items = 6    // Set this to a number greater than 5!
     
        if($items > 5) {
          echo "You get a 10% discount!";
        }
      ?>
    </p>
  </body>
</html>

Conditionals and Control Flow - 1/4 - codeacademy.com

Instructions: On line 8, use a comparison operator to compare two numbers. Make sure to end your line of code with a semicolon.



<html>
  <head>
    <title>Comparing Numbers</title>
  </head>
  <body>
    <p>
      <?php
        5<10;
      ?>
    </p>
  </body>
</html>
Comparing Numbers

Conditionals and Control Flow - 1/4 - codeacademy.com

Instructions: On line 8, use a comparison operator to compare two numbers. Make sure to end your line of code with a semicolon.



<html>
  <head>
    <title>Comparing Numbers</title>
  </head>
  <body>
    <p>
      <?php
        5<10;
      ?>
    </p>
  </body>
</html>
Comparing Numbers

Thursday, April 24, 2014

Introduction to PHP - 13/13 - codeacademy.com

Instructions: Let's finish this up! Beneath your existing PHP code, use echo to print out your name and your age, like so:

echo $myName;
echo $myAge;


<!DOCTYPE html>
<html>
    <head>
        <link type='text/css' rel='stylesheet' href='style.css'/>
<title>PHP FTW!</title>
</head>
<body>
 
        <p>
        <?php
        $myName = "Jowett";
        $myAge = 23;
     
        echo $myName;
        echo $myAge;
        ?>
     
        </p>
</body>
</html>

Introduction to PHP - 12/13 - codeacademy.com

Instructions:  After your first variable, declare a second, $myAge, and set it equal to your age as a number. Remember: no quotes around numbers!


<!DOCTYPE html>
<html>
    <head>
        <link type='text/css' rel='stylesheet' href='style.css'/>
<title>PHP FTW!</title>
</head>
<body>
 
        <p>
        <?php
        $myName = "Jowett";
        $myAge = 22;
        ?>
        </p>
</body>
</html>