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的更多相关文章
随机推荐
- nodejs npm insttall 带不带-g这个参数的区别
-g 中的g是global的意思所以带-g这个参数是全局安装,不带-g这个参数是本地安装. 在windows系统中全局安装的目录在:C:\Users\linsenq\AppData\Roaming\n ...
- centos6上使用fpm打python2.7 rpm包并兼容python2.6
centos6上使用fpm打python2.7 rpm包并兼容python2.6 作者 运维小兵_加油 关注 2016.09.22 00:28 字数 501 阅读 45评论 0喜欢 1 工作中我们常常 ...
- 简单配置oracle11g
一.配置 Systemd file(开机可以自动oracle,也可以查看启动状态) a.定义环境变量 [oracle@ol7 ~]$ cat /etc/sysconfig/DB11G.oracledb ...
- event对象和事件冒泡
<!DOCTYPE HTML><html><head> <meta charset="utf-8"> <title>无标 ...
- Java之戳中痛点 - (4)i++ 和 ++i 探究原理
先看一个例子: package com.test; public class AutoIncrement { public static void main(String[] args) { int ...
- NSMutableArray遍历删除注意事项
for (int i = 0; i < [array count]; i++) { [array removeObjectAtIndex:i]; } 上面的遍历由于在remove操作之后ar ...
- 代码管理工具 (含git、npm、gulp)
1 Git 分布式代码管理工具(基于Linux,可在本地进行提交)代码同时储存在本地和服务器中 ① Git基本操作命令 (1)初始化,创建初始化仓库 git init ------- 文件初始化,初始 ...
- bzoj 1293 贪心
首先我们可以将这道题看成一个数轴,数轴其中的某些点存在一些颜色,我们要选取最短的一段,使这段存 在所有颜色,那么我们使用指针i,j表示在j-i位置中包含的颜色,那么初值是0,0,我们先i++,同时添加 ...
- (七)计算G711语音的打包长度和RTP里timestamp的增长量
如何计算G711语音等的打包长度和RTP里timestamp的增长量 一般对于不同的语音有不同的打包周期,而不同的打包周期又对应着不同的timestamp in RTP 那么是如何计算的呢,我们通过G ...
- wscript运行js文件
wscript运行js文件 http://www.cnblogs.com/jxgxy/archive/2013/09/20/3330818.html wscript运行js文件 wscript ad ...