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

Majid Bilal
Majid Bilal
3,558 Points

If exact out put expected can be shared, it will enable me to complete this task.

I think I am doing it right but I keep getting the message that I am doing it wrong i.e. perhaps because I'm not getting what is the exact output needed.

index.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 " . $studentOneGPA  . " of 4.0";
}

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

2 Answers

Kent Åsvang
Kent Åsvang
18,823 Points

I don't remember this lesson, but it strikes me as odd that you are checking if the gpa is equal to 4.0. It sounds a lot more logical to check wether the gpa is above or equal to 4.0.

The same goes for your elses'. Your code;

else {
  echo $studentOneName . " has a " . $studentOneGPA  . " of 4.0";

and 

else {
    echo $studentTwoName . " has a " . $studentTwoGPA  . " of 4.0";
  • Will output : "Dave/ or Treasure has a 3.8/ or 4.0 of 4.0." It would make more sense to just display the studenGPAs and not the string "4.0" in all cases. So i'm guessing your code should look something like this :
<?php
$studentOneName = 'Dave';
$studentOneGPA = 3.8;

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

//Place your code below this comment
if ($studentOneGPA >= 4.0) {  //  Checks if the studentGPA is above or equal to 4.0
  echo $studentOneName . " made the Honor Role";
} else {
  echo $studentOneName . " has a GPA of " . $studentOneGPA ;  // Outputs the students gpa
}

if ($studentTwoGPA >= 4.0) { //  Checks if the studentGPA is above or equal to 4.0
  echo $studentTwoName . " made the Honor Role";
} else {
    echo $studentTwoName . " has a GPA of " . $studentTwoGPA; // Outputs the students gpa
}
?>

I hope this made some sense. Good luck.

Majid Bilal
Majid Bilal
3,558 Points

Thank you, that did the trick for me.