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 trialAndre Heath
Courses Plus Student 1,059 PointsWhat am i doing wrong in comparing these?
<?php $studentOneName = 'Dave'; $studentOneGPA = 3.8;
$studentTwoName = 'Treasure'; $studentTwoGPA = 4.0;
//Place your code below this comment if ($studentOneGPA == 4.0){ echo "$studentOneName has made the Honor Roll"; }else{ echo "$studentOneName has a $studentOneGPA of 4.0"; }
if ($studentTwoGPA == 4.0){ echo "$studentTwoName has made the Honor Roll"; }else{ echo "$studentTwoName has a $studentTwoGPA of 4.0"; } ?>
<?php
$studentOneName = 'Dave';
$studentOneGPA = 3.8;
$studentTwoName = 'Treasure';
$studentTwoGPA = 4.0;
//Place your code below this comment
if ($studentOneGPA == 4.0){
echo "$studentOneName has made the Honor Roll";
}else{
echo "$studentOneName has a $studentOneGPA of 4.0";
}
if ($studentTwoGPA == 4.0){
echo "$studentTwoName has made the Honor Roll";
}else{
echo "$studentTwoName has a $studentTwoGPA of 4.0";
}
?>
2 Answers
Alexander Davison
65,469 PointsTry changing "$studentOneName has a $studentOneGPA of 4.0" and "$studentTwoName has a $studentTwoGPA of 4.0" to "$studentOneName has a GPA of $studentOneGPA" and "$studentTwoName has a GPA of $studentTwoGPA".
Good Luck, Alex
Jennifer Nordell
Treehouse TeacherHi there! Would it be comforting to know that there's nothing wrong with your comparisons? It's the strings that you're echoing out that are incorrect.
Read carefully the instructions about how the strings are to be formatted. These must match exactly. Here's a few hints:
- you've written "has made" where they want just "made"
- The honor roll message only prints out when the GPA is 4.0 thus, if the honor roll message hasn't printed out the GPA wasn't 4.0, it was something else
- In the first scenario it should print out "Dave has a GPA of 3.8"
- Check the preview to see what is being printed out
Hope these hints help!