need to solve an exercise

Hello guys. i really need some help on this !! create a class which contains 2 private members expressing the coefficients of a first grade equation with 1 variable, a function that returns the number of equation's roots (consider n/0 and 0/0),and a function that returns the equation's root if it does exist.
Last edited on
What are you stuck on?
on creating this root's function, i can't find what kind of instruction to use and how to do that
Could you describe in a bit more detail what you're supposed to be doing?
I'm not quite understanding.
i'm sorry if you were teased by my posts , i didn't do it on purpose and i know u're not paid by answering my questions...anyway, this is a kind of test's exercise which consists on creating a class with the requirements above
It's not about that. Double posting something makes everyone here want to help you less. It's about manners. Double posting is impolite.

It's the requirements that I don't understand. Elaborate some more on them and I'll see if I can help you.
i'm supposing to create a class and some functions about that. the class should be named for example : class Equation{ ...its private members should be the equations coefficients (ex: 2x=8). now the function should return the equation's roots..i hope you understood
thnx for the advice btw i won't double post anymore
Last edited on
Okay, that shouldn't be too difficult, because by definition a first degree function has one and only one root.
So lets write some pseudocode for your problem.

For this program, let's define a function as the form y = ax + b.

In maths, when you're looking for a root you want to find the value of x when y is 0. So set y to zero, and solve for x.
0 = ax + b
-b = ax  <-- subtract b from both sides
x = -b/a <-- divide both sides by a


So now we have derived a formula to solve for the root of the linear equation.
Now you can have a function called roots, or something. Get the user to input the value of a and b, and return the value of -b/a, which we now know to be the root of the first degree function.

So, I've given you a really good starting point. Start writing some code and if you end up needing more help I'll be around :)
Last edited on
Topic archived. No new replies allowed.