+ 1

quadratic equation

public class Program { public static void main(String[] args) { float a = 1.0f ; float b = 2.0f ; float c = -3.0f ; float x =(float) (-b + Math.sqrt((b*b)-(4*a*c)))/(2*a); System.out.println(x); float y = (float) (-b - Math.sqrt((b*b)-(4*a*c)))/(2*a); System.out.println(y); } } QUESTION: 1. Why do we need include f (ex. 1.0f) in the initialization? 2. why do we need to mention float in the brackets in the formula statement?

8th Nov 2017, 7:26 AM
Hema Chander
Hema Chander - avatar
3 odpowiedzi
+ 2
thank you
8th Nov 2017, 7:45 AM
Hema Chander
Hema Chander - avatar
+ 1
thanks @gordie
8th Nov 2017, 5:24 PM
Hema Chander
Hema Chander - avatar
0
but we initialised "a" as a float why we need to add f after 1.0?
8th Nov 2017, 7:41 AM
Hema Chander
Hema Chander - avatar