dateFashion
From ggc
http://www.javabat.com/prob?id=Logic.dateFashion
public int dateFashion(int you, int date) {
If(you >=8 || date >=8)
{
return 2;
}
else if(you <=2 || date <=2)
{
return 0;
}
return 1;
}
I feel like I almost have it but I cant even get it to run. Says I need a ; after >=8 but thats not right when i put one there
Answer: It had more to do with your placement of when you check for 8 and when you check for 2. You should have done the check for 2 before the check for 8 because if you do the check for 8 first it can cause a {return 2;} for a value of 8 , 2 when it should just return 0.
Also your 'else' needs to go after the {return 0;}
Solution
public int dateFashion(int you, int date) {
if (you <=2 || date <=2)
{return 0;}
else
if (you >= 8 || date >= 8)
{return 2;}
else
{return 1;}
}
- This page was last modified on 2 April 2008, at 00:05.
- This page has been accessed 582 times.
- Privacy policy
- About ggc
- Disclaimers
- Powered by MediaWiki!









