The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
quadratic equation
Posted by: quadratic equation | September 24, 2009 @ 8:19am
Java Code
[
Download
]
import java.io.*; public class roots { public static void main(String args[]) { int a,b,c; double r1,r2; try{ BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); System.out.println("input values of a quadratic equation"); System.out.println("value of a"); a=Integer.parseInt(in.readLine()); System.out.println("value of b"); b=Integer.parseInt(in.readLine()); System.out.println("value of c"); c=Integer.parseInt(in.readLine()); System.out.println (Math.sqrt(Math.pow(b,2)-4*a*c)); r1=(-1)*b + Math.sqrt(Math.pow(b,2)-4*a*c); r2=(-1)*b - Math.sqrt(Math.pow(b,2)-4*a*c); System.out.println("roots:"+r1 + ","+r2); } catch (Exception e) {} } }
Syntax Highlighting
[
Open in new window
]
Author Comments
none
Rating
4.39 / 8
100 Votes
http://codebin.yi.org/391
page generated in 0.00 seconds