Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP PHP Basics Daily Exercise Program Conditionals

Check if each student has a GPA of 4.0. If the student has a GPA of 4.0, use the students name variable to display "NA

<?php
$studentOneName = 'Dave';
$studentOneGPA = 3.8;

$studentTwoName = 'Treasure';
$studentTwoGPA = 4.0;

//Place your code below this comment
if($studentOneName == 4.0 ){
$studentOneName. " made the Honor Role";
} else {$studentOneName. " has a GPA of ". $studentOneGPA }

if ($studentTwoName === 4.0){
 $studentTwoName. " made the Honor Role"; 
} else {$studentTwoName. " has a GPA of ". $studentOneGPA }
?>

Why is this code no good this should work

index.php
<?php
$studentOneName = 'Dave';
$studentOneGPA = 3.8;

$studentTwoName = 'Treasure';
$studentTwoGPA = 4.0;

//Place your code below this comment

?>

Hi John, i left the code down here. This work to me. The problem is that is missing the "echo" the results of the if or else statements. :)

14 Answers

Ok, send me a screen of the bummer fail with the code, to take a look if you want.

Wow, Jennifer you're right! Thank you you both so much! I really appreciate you lost your time on me.

<?php
$studentOneName = 'Dave';
$studentOneGPA = 3.8;

$studentTwoName = 'Treasure';
$studentTwoGPA = 4.0;

//Place your code below this comment
if ($studentOneGPA == 4.0){
 echo  $studentOneName . " made the Honor Role";
} else {  echo $studentOneName . " has a GPA of " . $studentOneGPA;
  }
if ($studentTwoGPA == 4.0){
 echo  $studentTwoName . " made the Honor Role";
} else {  echo $studentTwoName . " has a GPA of " . $studentTwoGPA;
  }
?>

It still does not pass

Hi guys! This should work! :)

<?php $studentOneName = 'Dave'; $studentOneGPA = 3.8;

$studentTwoName = 'Treasure'; $studentTwoGPA = 4.0;

//Place your code below this comment if ( $studentOneGPA == 4.0 ) { echo $studentOneName . ' made the Honor Role'; } else { $studentOneName . ' has a GPA of ' . "$studentOneGPA"; } if ( $studentTwoGPA == 3.0 ) { echo $studentTwoName. ' made the Honor Role'; } else { echo $studentTwoName . ' has a GPA of ' . $studentTwoGPA; } ?>

<?php
$studentOneName = 'Dave';
$studentOneGPA = 3.8;

$studentTwoName = 'Treasure';
$studentTwoGPA = 4.0;

//Place your code below this comment
if ( $studentOneGPA == 4.0 ) {
  echo $studentOneName . ' made the Honor Role';
} else {
  $studentOneName . ' has a GPA of ' . "$studentOneGPA";
}
  if ( $studentTwoGPA == 3.0 ) {
  echo $studentTwoName.  ' made the Honor Role';
} else {
  echo  $studentTwoName . ' has a GPA of ' .  $studentTwoGPA;
  }
?>

I have the same problem. I tried to use all of the proposed codes but it says "Bummer! fail"

Hi Orest did you tryed with the code I left above?

Hi, Juan. Yes I tried all versions I had found on the forum and even internet. Every time I get one error, think it's a problem on "veryfication system"((

Sure, here is a screenshot of browser http://imgur.com/a/aTGGb

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hiya Orest Ivasyk! They've modified the spelling in this challenge since it was originally posted, which is why your echo statements are not working. The correct spelling is "Honor Roll" ... not "Honor Role". So using the code posted above won't work. That code was only valid before they changed the spelling of "Role" to "Roll". Hope this helps! :sparkles:

Wow, Jennifer you're right! Thank you both so much! I really appreciate you lost your time on me.

The problem is that you're NOT "echo" the first else statement, and you're using single quotes for calling a variable value. So try this: insert an "echo" in the first else statement and call the $studentOneGPA variable without quotes. Let me know!! and good luck. \\php <?php $studentOneName = 'Dave'; $studentOneGPA = 3.8;

$studentTwoName = 'Treasure'; $studentTwoGPA = 4.0;

//Place your code below this comment if ( $studentOneGPA == 4.0 ) { echo $studentOneName . ' made the Honor Role'; } else { echo $studentOneName . ' has a GPA of ' . $studentOneGPA; } if ( $studentTwoGPA == 4.0 ) { echo $studentTwoName. ' made the Honor Role'; } else { echo $studentTwoName . ' has a GPA of ' . $studentTwoGPA; } ?>

Yes, It works for me when I fixed 'The correct spelling is "Honor Roll" ... not "Honor Role".' and added 'echo'. Thank you.

$studentOneName = 'Dave';
$studentOneGPA = 3.8;

$studentTwoName = 'Treasure';
$studentTwoGPA = 4.0;

//Place your code below this comment
if ( $studentOneGPA == 4.0 ) {
  echo $studentOneName . ' made the Honor Role';
} else {
  echo $studentOneName . ' has a GPA of ' . $studentOneGPA;
}
  if ( $studentTwoGPA == 4.0 ) {
  echo $studentTwoName.  ' made the Honor Role';
} else {
  echo  $studentTwoName . ' has a GPA of ' .  $studentTwoGPA;
  }
?>

Great! You're welcome! :)