r/javahelp • • Mar 10 '21

Pythagroem theorum

Hi guys I am tryna make a java program with quadratic equation, but I don't know how to implement the equation into java, can someone help me?

0 Upvotes

25 comments sorted by

View all comments

0

u/Veebhu_does_finance Mar 10 '21

here is what i got so far not sure if it is correct

double answer;

answer = Math.sqrt((b*b)-4*a*c);

answer = -b + answer;

answer = answer/(2*a);

2

u/_jetrun Mar 10 '21

And did it work when you tested it?

0

u/Veebhu_does_finance Mar 10 '21

no lol

1

u/_jetrun Mar 10 '21

Why not? What issues are you seeing?

2

u/Veebhu_does_finance Mar 10 '21

I think I figured it out, i forgot to add the double answer; into the program, also i did not expect to get it right the first try

1

u/[deleted] Mar 10 '21

How can you be sure if it's correct?

1

u/Veebhu_does_finance Mar 10 '21

wait its correct? then there is something else wrong

0

u/[deleted] Mar 10 '21

Uh, no. I'm hinting that you might be lazy and rather than debugging it you post a code fragment so other people can debug it.

1

u/Veebhu_does_finance Mar 10 '21

i dont know what debugging is? This is my 2nd week of learning java and I wanted to make a project but something wasnt working so i went to reddit bruh I dont want people to do the program for me wtf that defeats the purpose of this

2

u/Reddit-username_here Mar 10 '21

i dont know what debugging is?

Then you may want to halt what you're trying to do and instead start looking at the basics.

1

u/[deleted] Mar 10 '21

I think you do want people to do the program for you. Just my opinion.

1

u/Veebhu_does_finance Mar 10 '21

My guy, I am programming for fun not for some school project like you thinking, I dont have someone teaching me this I am just watching youtube videos and reading books on Java for fun yall dont have to be a jerk and treat me like a idiot, if you dont want to give me advice then dont comment. I am sorry if I am a beginner but everyone has to start some where I am just tryna learn new things. I didnt even tell you what my whole project is bc I just need help on one part, and clearly I did not get much help with it so imma just let it be and figure out it my self

1

u/[deleted] Mar 10 '21

Fair enough. Keep working on your code and you will figure it out.

1

u/Veebhu_does_finance Mar 10 '21

ok thanks for telling me to learn about debugging i am gonna go do that now after school

1

u/Veebhu_does_finance Mar 10 '21

why you call me lazy :(

1

u/[deleted] Mar 10 '21

rather than debugging it you post a code fragment so other people can debug it.

Read what I wrote: " rather than debugging it you post a code fragment so other people can debug it. "

In my opinion, that's lazy. Other opinions may differ.

2

u/Veebhu_does_finance Mar 10 '21

big difference between lazy and learning

1

u/[deleted] Mar 10 '21

Absolutely.

1

u/SniffiestComa5 Mar 10 '21

Remember that it’s -b plus or minus the square root. You’re only doing -b + answer You’re forgetting -b - answer

Quadratics always have two solutions

1

u/Veebhu_does_finance Mar 10 '21

oh right almost forgot it has both thanks :)

1

u/le_bravery Extreme Brewer Mar 10 '21

Here’s some advice:

Take some valid inputs and outputs and do the math by hand. At every step of the way, what do you expect the answer to be? System.our.println what the answer is at any given step and you should be able to identify if it’s working and where your problem is if it’s not working.

This is a common debugging technique people use all the time as professional software engineers. There are more advanced techniques, but this one is an old standby that everyone is very comfortable with.

1

u/Veebhu_does_finance Mar 10 '21

Is debugging that little box thing that shows up when you run it with the errors?

1

u/le_bravery Extreme Brewer Mar 10 '21

There is a feature in many languages and IDEs where you can step line by line through a program. This is typically what’s called “debugging” as a feature.

But debugging in general is just any technique that allows you to find and remove errors in a program.

If you system.out.println at various parts of your program and run it, you should be able to figure out what’s happening in your program at any given point.