• Post Reply Bookmark Topic Watch Topic
  • New Topic

[Codingbat Question] Can't figure out what I'm doing wrong  RSS feed

 
asdsfasfas ghsgh
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm doing this tutorial: http://codingbat.com/prob/p116624

Using this code



I can't figure out why it won't give me the correct results. Could someone help me?
 
Ahsan Bagwan
Ranch Hand
Posts: 254
1
Java MySQL Database Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You want to return the result from the conditional statement also I presume.

Another thing is you are not calculating the absolute difference in your if condition in the first place before you are doubling it.
 
Raymond Tong
Ranch Hand
Posts: 255
2
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
return double the absolute different if n is over 21

but you have doubled n if n is over 21.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!