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的更多相关文章
随机推荐
- PropertiesConfiguration的用法
PropertiesConfiguration是一个配置文件的加载工具类,封装了从配置文件里获取值并转化为基本数据类型的方法. 使用org.apache.commons.configuration2中 ...
- JavaScript学习笔记——浅拷贝、深拷贝
参考自:http://www.cnblogs.com/yichengbo/archive/2014/07/10/3835882.html 一.数组的深浅拷贝 在使用JavaScript对数组进行操作的 ...
- ACdream 1113 The Arrow (概率dp求期望)
E - The Arrow Time Limit:1000MS Memory Limit:64000KB 64bit IO Format:%lld & %llu Submit ...
- wiki1285
2013-09-21 16:50 裸 //By BLADEVIL var n :longint; i :longint; x, y :longint; t, tot :longint; key, s, ...
- 【转】vs2015一键卸载干净
插件是国外的一位同行写的,偶然在网上发现感觉挺好用,分享一下. 第二步.下载工具并解压 网盘下载地址:https://pan.baidu.com/s/1eSHRYxW 也可以在Github上下载最新版 ...
- 以root启动pycharm
在使用scapy模块的时候提示permitted就猜想可能是权限问题.然后换成root启动啥事情都没了. 由于本机是deepin先找到pycharm.sh脚本 然后再执行sudo ./pycharm. ...
- 利用os、hash模块生成目录下所有文件的md5
hashlib用于对字符串或者文件进行加密. 使用方法1: hashlib.md5('str').hexdigest() 使用MD5对str进行加密,使用hexdigest(),16进制的方式打印 ...
- mininet+floodlight搭建sdn环境并创建简单topo
第一步:安装git sudo apt-get update sudo apt-get install git 测试git是否安装成功: git 第二步:安装mininet 1.获取mininet最新源 ...
- 8.read读取控制台输入
read(选项)(参数)选项:-p:指定读取值时的提示符-t:指定读取时等待的时间(秒),如果没有在指定的时间内输入,就不再等待了参数:变量:指定读取时的变量名
- CSS3颜色渐变模式总结
1.线性渐变:linear-gradient 语法:= linear-gradient([ [ | to [, ]+) = [left | right] || [top | bottom] = [ | ...