Alright so I'm coding a Quadratic Equation Solver to help with my Math Class. However the teacher requires each calculation to be written out. I have the solver working, however I'm not sure where to start when it comes to printing each step. I know I will need to `System.out.println()` each step. But how does Java interpret the equation? Does it do proper BEDMAS(Brackets, Exponents, Division, Multiplication, Addition, Subtraction)? if(disc == 0) { x1 = (-b+Math.sqrt(Math.pow(b, 2)-4*a*c))/(2*a); System.out.println("One Root Found: " + x1); } else if(disc > 0) { x1 = (-b+Math.sqrt(Math.pow(b, 2)-4*a*c))/(2*a); x2 = (-b-Math.sqrt(Math.pow(b, 2)-4*a*c))/(2*a); //Output Results System.out.println("Two … |
+0 forum
3 | ||

Review for a final and I had a question... You are give a hash function h(x) = x%11 and the size of the hash table is 11. The inputs are 4371,1323,6173,4199,4344,9679,1989. What would the resulting hash table be using quadratic probing. Would I start with 4371 and then do the following (h(x)+i^2)%size = location ? h(x) = 4371mod11 = 4 size = 11 i = ??? Not sure thanks for any help (the book is confusing me even more ). |
+0 forum
3 | ||

Hello...just started learning C and i'm trying to write a program that solves quadratic equations...but every time i compile and run it and enter the 3 variables it crashes. I kept on looking but didn't find anything wrong with it...help? :P [CODE]#include <stdio.h> main(){ int a,b,c; float x1,x2; printf("Please enter a b c: \n"); scanf("%d %d %d",a,b,c); if (a == 1){ x1= (b/2) + sqrt(pow(b/2,2)-c); x2= (b/2) - sqrt(pow(b/2,2)-c); } else { x1= (b+ sqrt(pow(b,2) - 4*a*c))/(2*a); x2= (b- sqrt(pow(b,2) - 4*a*c))/(2*a); } printf("The solutions are: \n%f ja %f",x1,x2); getch(); }[/CODE] |
+0 forum
3 | ||

im trying to write a code that i can input a,b,c and the code will run it in the quadratic formula and give me the answer but i keep getting a error problem import math from math import sqrt print print ("Welcome to the Quadratic Program") print ("--------------------------------") print a=input("Enter a: ") b=input("Enter b: ") c=input("Enter c: ") print print answer=[b+(math.sqrt((b*b)-(4*a*c)))]/(2*a) if answer<0: print ("negative") print answer |
+0 forum
2 |

The End.