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的更多相关文章

随机推荐

  1. django自己搭建的博客

    1.博客地址: http://jiangtao4.pythonanywhere.com/ 2.后台可以发布笔记,可以翻页,数据存在MySQL里面 3.GitHub地址: https://github. ...

  2. webpack 的第三方库分离并持久化缓存

    我们常常需要在浏览器缓存一些稳定的资源,如第三方库等.要达到这个目标,只需要两步: 1.提取出“稳定的资源”: 2.提供稳定的文件hash . 处理后的出的文件就像这样子: app.1w3ad4q4. ...

  3. es6+最佳入门实践(11)

    11.async函数 async 函数是什么?一句话,它就是 Generator 函数的语法糖.通俗的说就是Generator函数的另一种写法,这种写法更简洁,除此之外,async函数还对Genrat ...

  4. 前端跨域之jsonp跨域

    jsonp跨域原理 原理:因为通过script标签引入的js是不受同源策略的限制的(比如baidu.com的页面加载了google.com的js).所以我们可以通过script标签引入一个js或者一个 ...

  5. P3076 [USACO13FEB]出租车Taxi

    题目描述 Bessie is running a taxi service for the other cows on the farm. The cows have been gathering a ...

  6. DB 基本性能指标

    DB: •500K I/O limit with kill(5M I/O limit for DWS) •10,000 return row limit with kill •30 seconds p ...

  7. bzoj 1951 lucas crt 费马小定理

    首先假设输入的是n,m 我们就是要求m^(Σ(c(n,i) i|n)) mod p 那么根据费马小定理,上式等于 m^(Σ(c(n,i) i|n) mod  (p-1)) mod p 那么问题的关键就 ...

  8. GridPanel分页条插件

    GridPanel的分页条没有设置当前页显示条数的功能,会不大方便 主要是抄袭的http://www.cnblogs.com/badwps/archive/2011/04/15/2016440.htm ...

  9. mysql六:索引原理与慢查询优化

    一 介绍 为何要有索引? 一般的应用系统,读写比例在10:1左右,而且插入操作和一般的更新操作很少出现性能问题,在生产环境中,我们遇到最多的,也是最容易出问题的,还是一些复杂的查询操作,因此对查询语句 ...

  10. 数据类型转换,JS操作HTML

    数据类型转换 1.自动转换(在某种运算环境下) Number环境 String环境 Boolean环境 2.强制类型转换 Number() 字符串:纯数字和空字符转为正常数字,其他NaN 布尔值:tu ...