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

John Lukacs
John Lukacs
26,806 Points

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

?>
Juan Ignacio Lambardi
Juan Ignacio Lambardi
3,943 Points

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

Juan Ignacio Lambardi
Juan Ignacio Lambardi
3,943 Points

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

Orest Ivasyk
Orest Ivasyk
16,198 Points

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

John Lukacs
John Lukacs
26,806 Points
<?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

Juan Ignacio Lambardi
Juan Ignacio Lambardi
3,943 Points

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; } ?>

Juan Ignacio Lambardi
Juan Ignacio Lambardi
3,943 Points
<?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;
  }
?>
Orest Ivasyk
Orest Ivasyk
16,198 Points

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

Juan Ignacio Lambardi
Juan Ignacio Lambardi
3,943 Points

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

Orest Ivasyk
Orest Ivasyk
16,198 Points

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"((

Orest Ivasyk
Orest Ivasyk
16,198 Points

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:

Orest Ivasyk
Orest Ivasyk
16,198 Points

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

Juan Ignacio Lambardi
Juan Ignacio Lambardi
3,943 Points

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; } ?>

Orest Ivasyk
Orest Ivasyk
16,198 Points

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

Juan Ignacio Lambardi
Juan Ignacio Lambardi
3,943 Points
$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;
  }
?>