# Ch4_prob7 - c = console.nextInt(); if ((b*b)-(4*a*c)>=0)...

This preview shows pages 1–2. Sign up to view the full content.

import java.util.Scanner; import java.lang.*; import java.io.*; import java.text.*; import java.math.*; import java.text.DecimalFormat; import java.lang.String; i public class Ch4_prob7 { public static void main(String[] args) throws FileNotFoundException, IOException { double firstAnswer, secondAnswer, a, b, c; System.out.println("*********************************************"); System.out.println("* The purpose of this program is to *"); System.out.println("* tell what kind of roots the formula has *"); System.out.println("* by inputing from a keyboard. *"); System.out.println("* *"); System.out.println("*********************************************"); System.out.println(); Scanner console = new Scanner(System.in); System.out.println("Please enter your a value"); a = console.nextInt(); System.out.println("Please enter your b value"); b = console.nextInt(); System.out.println("Please enter yout c value");

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: c = console.nextInt(); if ((b*b)-(4*a*c)>=0) { System.out.println("the equation has to real roots "); System.out.println(); firstAnswer = (-b - Math.sqrt(Math.pow(b, 2) - 4 * a * c))/(2*a); secondAnswer = (-b + Math.sqrt(Math.pow(b, 2) - 4 * a * c))/(2*a); System.out.printf("firstAnswer : %10.2f %n", (firstAnswer)); System.out.printf("secondAnswer : %10.2f %n", (secondAnswer)); } else { System.out.println("the equation has two complex roots"); System.out.println(); firstAnswer = (-b - Math.sqrt(Math.pow(b, 2) - 4 * a * c))/(2*a); secondAnswer = (-b + Math.sqrt(Math.pow(b, 2) - 4 * a * c))/(2*a); System.out.printf("firstAnswer : %10.2f %n", (firstAnswer)); System.out.printf("secondAnswer : %10.2f %n", (secondAnswer)); } System.out.println(); System.out.println("Thank you for using this program."); System.out.println("You must now pay me TEN BUCKS!!"); } }...
View Full Document

## This note was uploaded on 06/17/2011 for the course COMPUTER S 2301 taught by Professor Staff during the Spring '11 term at Kennesaw.

### Page1 / 2

Ch4_prob7 - c = console.nextInt(); if ((b*b)-(4*a*c)>=0)...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online