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 trialBIRIMA BURMA
1,030 PointsHi! I,am again with if else training!
bool hasBonus;
int powerPoints=5;
if (powerPoints>3;)
hasBonus= false;
else {powerPoints<=3;}
hasBonus= true;
3 Answers
Caleb Kleveter
Treehouse Moderator 37,862 PointspowerPoints
needs to equal 0. Also, use an if-else
statement:
Task 1
bool hasBonus;
int powerPoints = 0;
Task 2
if (powerPoints < 3){
hasBonus = false;
} else {
hasBonus = true;
}
Caleb Kleveter
Treehouse Moderator 37,862 Points- The first part of the
if-statement
is missing it's parentheses. - You don't place a conditional for an
else-statement
. - No semi-colons in
if-statements
- Should
hasBonus
be set to true if you have more then 3 power points, and not the other way around?
bool hasBonus;
int powerPoints=5;
if (powerPoints > 3) {
hasBonus= false;
} else {
hasBonus= true;
}
BIRIMA BURMA
1,030 Pointsbool hasBonus;
int powerPoints=5;
if (powerPoints <3){
hasBonus=false;
}
if (powerPoints>=3){
hasBonus=true;
}