Exercise03_01
import javax.swing.JOptionPane;
public class TheDirection {
public static void main(String[] args){
double a,b,c,t,r1,r2;
String number;
int messageType=JOptionPane.INFORMATION_MESSAGE;
number=JOptionPane.showInputDialog(null,"输入a");
a=Double.parseDouble(number);
number=JOptionPane.showInputDialog(null,"输入b");
b=Double.parseDouble(number);
number=JOptionPane.showInputDialog(null,"输入c");
c=Double.parseDouble(number);
t = b*b-4*a*c;
if(t>0){
r1 = (-b+Math.pow(t,0.5))/(2*a);
r2 = (-b-Math.pow(t,0.5))/(2*a);
String message="The equation has two roots " + r1 + " and "+ r2;
JOptionPane.showMessageDialog(null,message,"result",messageType);
}
else if(t==0){
r1 = (-b+Math.pow(t,0.5))/(2*a);
String message="The equation has one roots " + r1;
JOptionPane.showMessageDialog(null,message,"result",messageType);
}
else{
String message="The equation has no real roots ";
JOptionPane.showMessageDialog(null,message,"result",messageType);
} }
}
Exercise03_01的更多相关文章
随机推荐
- Java之戳中痛点 - (3)三目运算符的两个操作数类型尽量一致
先看一个例子: package com.test; public class TernaryOperator { public static void main(String[] args) { in ...
- iOS 单元测试(Unit Test 和 UI Test)
之前一直搞过~~最近试了一下下,完美~~ 附上一篇文章,不同的伙伴可以看看: http://www.jianshu.com/p/009844a0b9edUnitTest(简单的单元测试使用) http ...
- 关于applePay详细讲解
https://www.cnblogs.com/diweinan/p/6225501.html
- charles 踩坑记录
charles破解教程:http://www.jianshu.com/p/12e75eb8f53d 1.需注意软件和破解脚本的版本是否正确(例如3.x.x版本的破解脚本不能用于4.x.x版本的char ...
- Python 入门学习笔记
安装和运行 官网下载安装包https://www.python.org/downloads/mac-osx/下载完直接安装即可 运行打开 terminal,输入命令 python,进入 python ...
- 【转】vs2015一键卸载干净
插件是国外的一位同行写的,偶然在网上发现感觉挺好用,分享一下. 第二步.下载工具并解压 网盘下载地址:https://pan.baidu.com/s/1eSHRYxW 也可以在Github上下载最新版 ...
- hdu 2544 最短路 (dijkstra,floyd)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2544 题目大意:找到两点间最短的距离值. 代码一:(dijkstra算法) #include < ...
- The Clean Architecture--一篇很不错的关于架构的文章
翻译水平有限,见谅! Uncle Bob 13 Aug 2012 Architecture Craftsmanship Over the last several years we’ve seen a ...
- 跟我一起写 Makefile(一)【转】
转自:http://blog.csdn.net/haoel/article/details/2886 跟我一起写 Makefile 陈皓 概述—— 什么是makefile?或许很多Winodws的程序 ...
- jQuery-niceScroll使用中父子div都存在滚动条导致错位的问题
1.做项目时因为客户要求改变了项目的整体样式,所以导致浏览器自带的滚动条样式与项目的样式风格格格不入,所以要使用一个滚动条插件来替换浏览器自带的滚动条,我在网上搜了下,发现niceScroll这个滚动 ...