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 trialJohn Lukacs
26,806 PointsCheck 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
<?php
$studentOneName = 'Dave';
$studentOneGPA = 3.8;
$studentTwoName = 'Treasure';
$studentTwoGPA = 4.0;
//Place your code below this comment
?>
14 Answers
Juan Ignacio Lambardi
3,943 PointsOk, send me a screen of the bummer fail with the code, to take a look if you want.
Orest Ivasyk
16,198 PointsWow, Jennifer you're right! Thank you you both so much! I really appreciate you lost your time on me.
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
3,943 PointsHi 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
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
16,198 PointsI have the same problem. I tried to use all of the proposed codes but it says "Bummer! fail"
Juan Ignacio Lambardi
3,943 PointsHi Orest did you tryed with the code I left above?
Orest Ivasyk
16,198 PointsHi, 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
16,198 PointsSure, here is a screenshot of browser http://imgur.com/a/aTGGb
Jennifer Nordell
Treehouse TeacherHiya 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!
Orest Ivasyk
16,198 PointsWow, Jennifer you're right! Thank you both so much! I really appreciate you lost your time on me.
Juan Ignacio Lambardi
3,943 PointsThe 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
16,198 PointsYes, It works for me when I fixed 'The correct spelling is "Honor Roll" ... not "Honor Role".' and added 'echo'. Thank you.
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;
}
?>
Juan Ignacio Lambardi
3,943 PointsGreat! You're welcome! :)
Juan Ignacio Lambardi
3,943 PointsJuan Ignacio Lambardi
3,943 PointsHi 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. :)