+ 1

Float in java and c++...( a beginner issue)

Hello there! I'm trying to write a code to find the slope of two points but both of my code in c++ and java keep giving me int results or 0.0 even when i declared all my variables in float or double https://code.sololearn.com/c5XNTpjH2R6W/?ref=app

5th Oct 2019, 12:28 PM
Angel
Angel - avatar
4 Respostas
+ 6
Angel there is a little mistake. See this line: float slope = ((y2-y2)/(x2-x1)); Did you notice you are subtracting y2 from y2 that is y2-y2. You just need to write y2-y1 in that place. ☺ and one more you have declared variable y on line 12 not y1 so do change it. You'll understand this after writting few more programs.. keep practicing. Improve debugging skill. All the best. Never give up 😊
5th Oct 2019, 12:35 PM
🇮🇳Omkar🕉
🇮🇳Omkar🕉 - avatar
+ 4
Angel you are welcome. And I'll suggest you to use another IDE for learning java as handling multiple inputs and finding bugs is quite hard here on sololearn. If you have PC you can try intellIJ IDEA or Eclipse. A good way to practice on Android is to use Jvdroid. You can search for others also.. Here is link to Jvdroid https://play.google.com/store/apps/details?id=ru.iiec.jvdroid
5th Oct 2019, 12:43 PM
🇮🇳Omkar🕉
🇮🇳Omkar🕉 - avatar
+ 2
Omg how i did not notice XD i was so stressed out to realise that Thank you so much, you are a life saver
5th Oct 2019, 12:38 PM
Angel
Angel - avatar
0
🇮🇳Omkar🕉 thank you so much, I'm gonna write them down on my notebook. i use Eclipse to coding, it's really helpful. I'm a computer science student. All my respect to you.
5th Oct 2019, 12:47 PM
Angel
Angel - avatar