Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

quadratatic equation solver  RSS feed

 
Jesus Rod Valenzuela
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I'm having troubles trying to display a quadratic solver that uses nested if statements to determine how the equation should be printed.
this is what i got. please help!!



[HENRY: fixed code tags]
   
 
Norm Radder
Ranch Foreman
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please explain what the problem is.  Post the current output and add some comments saying what is wrong with it.

uses nested if statements

The code is missing all the nested if statements' indentations.  Please update the code and fix the indentations to make the code easier to read and understand.
 
Jesus Rod Valenzuela
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need the program to change the quadratic term when it is 1 to just x^2, and do the same when the linear term is 1 juts x
 
Norm Radder
Ranch Foreman
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please  Post the current output and add some comments saying what is wrong with it.
Show what you want the output to look like.
 
Jesus Rod Valenzuela
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Enter the  coefficient of the  quadratic term -> 9

Enter the  coefficient of the  linear  term -> 0

Enter the  constant  term -> 16

For the  quadratic equation  9.00000x^2+16.00000=0

Enter the  coefficient of the  quadratic term -> 9

Enter the  coefficient of the  linear  term -> 16

Enter the  constant  term -> 0

For the  quadratic equation  9.00000x^2+16.00000x=0
something like that

 
Norm Radder
Ranch Foreman
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If that is the program's current output, please add some comments showing where it is wrong and show what it should be.
For example:
For the  quadratic equation  9.00000x^2+16.00000x=0  <<<*** wrong
The output should be: For the  quadratic equation  9.0x^2+16.0x=77
 
Campbell Ritchie
Marshal
Posts: 55681
161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Your main method is much too long and is trying to do too many things. Create methods for input and check that they are working. Create a method for solving the equations and check that they are working, separately. But before you do that, write down in very simple words how you are going to solve the equations, because those instructions will be easy to turn into code.
Avoid ^2; use \u00b2 inside your Strings instead.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!