CodeGym
CodeGym University
Learning
Course
Tasks
Surveys & Quizzes
Games
Help
Schedule
Community
Users
Forum
Chat
Articles
Success stories
Activity
Reviews
Subscriptions
Light theme
Question
  • Reviews
  • About us
Start
Start learning
Start learning now
  • All questions
Deepak Joshi
Level 17
Nainital
  • 26.04.2019
  • 965views
  • 6comments

What's wrong with this code?

Question about the task Closest to 10
Java Syntax,  Level 4,  Lesson 4
Under discussion
0
Comments (6)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Guadalupe Gagnon
Level 37 , Tampa, United States
26 April 2019, 15:44
Share your code like this: .
0
Deepak Joshi
Level 17 , Nainital, India
1 May 2019, 13:28
I cannot attach the code. I have solved the question so this option is showing me cross. But my confusion is not clear. With a little bit of modification to my code, it gets passed. If you have free time try to figure it out plz I am attaching some screenshots.
0
Guadalupe Gagnon
Level 37 , Tampa, United States
1 May 2019, 13:37
it should be num1 = abs(a - 10); num2 = abs(b - 10); checking if a and b are less than or equal to 0 is a redundant step.
0
Guadalupe Gagnon
Level 37 , Tampa, United States
1 May 2019, 14:10
Though I do not know why the code failed before you added the extra abs like this: abs(abs(a) + 10). I have tested it and it makes no difference to the outcome. Must just be a quirk in the validation system.
0
Deepak Joshi
Level 17 , Nainital, India
1 May 2019, 14:21
Yeah man! it is a redundant step. Thanx
0
Deepak Joshi
Level 17 , Nainital, India
1 May 2019, 14:23
But for the failing query maybe its a system fault.
+1
Learn
  • Registration
  • Java Course
  • Help with Tasks
  • Pricing
  • Game Projects
  • Java Syntax
Community
  • Users
  • Articles
  • Forum
  • Chat
  • Success Stories
  • Activity
  • Affiliate Program
Company
  • About us
  • Contacts
  • Reviews
  • Press Room
  • CodeGym for EDU
  • FAQ
  • Support
CodeGym CodeGym is an online course for learning Java programming from scratch. This course is a perfect way to master Java for beginners. It contains 1200+ tasks with instant verification and an essential scope of Java fundamentals theory. To help you succeed in education, we’ve implemented a set of motivational features: quizzes, coding projects, content about efficient learning and Java developer’s career.
Follow us
Interface language
Programmers Are Made, Not Born © 2023 CodeGym
MastercardVisa
Programmers Are Made, Not Born © 2023 CodeGym
This website uses cookies to provide you with personalized service. By using this website, you agree to our use of cookies. If you require more details, please read our Terms and Policy.