Java基础问题求解

GUI编程,需要一个程序,运行后显示如图结果。谢谢大神!

第1个回答  2017-06-03

<!--  懒癌发作 实在不想写 这是以前写的计算器 您参考一下吧  -->
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <style type="text/css">
            .shuZi{
                background-color:#99FFCC;
                border: none;
            }
            .shanChu{
                background-color:coral;
                border: none;
            }
            .yunSuanFu{
                background-color:greenyellow;
                border: none;
            }
        </style>
    </head>
    <body>
        <input type="text" class="" name="" id="pingMu" value="" />
        <table border="1">
            <tr>
                <td>
                    <input class="shanChu" onclick="shanChu(this)" type="button" value="←" style="background-color: #99FFCC; border: none; width:125px; height:100px; padding:0px;a"/>
                </td>
                <td>
                    <input class="shanChu" onclick="shanChu(this)" type="button" value="CE" style="background-color: #99FFCC; border: none; width:125px; height:100px; padding:0px;a"/>
                </td>
                <td>
                    <input class="shanChu" onclick="shanChu(this)" type="button" value="C" style="background-color: #99FFCC; border: none; width:125px; height:100px; padding:0px;a"/>
                </td>
                <td>
                    <input class="yunSuanFu" onclick="yunSuan(this)" type="button" value="=" style="background-color: cornflowerblue; border: none; width:125px; height:100px; padding:0px;a"/>
                </td>
            </tr>
            <tr>
                <td>
                    <input class="shuZi" onclick="shuZi(this)" class="suZiEnJian" type="button" value="7" style="background-color:greenyellow; border: none; width:125px; height:100px; padding:0px;a"/>
                </td>
                <td>
                    <input class="shuZi" onclick="shuZi(this)" class="suZiEnJian" type="button" value="8" style="background-color:greenyellow; border: none; width:125px; height:100px; padding:0px;a"/>
                </td>
                <td>
                    <input class="shuZi" onclick="shuZi(this)" class="suZiEnJian" type="button" value="9" style="background-color:greenyellow; border: none; width:125px; height:100px; padding:0px;a"/>
                </td>
                <td>
                    <input class="yunSuanFu" onclick="yunSuan(this)" type="button" value="/" style="background-color: cornflowerblue; border: none; width:125px; height:100px; padding:0px;a"/>
                </td>
            </tr>
            <tr>
                <td>
                    <input class="shuZi" onclick="shuZi(this)" class="suZiEnJian" type="button"value="4" style="background-color:greenyellow; border: none; width:125px; height:100px; padding:0px;a"/>
                </td>
                <td>
                    <input class="shuZi" onclick="shuZi(this)" class="suZiEnJian" type="button"value="5" style="background-color:greenyellow; border: none; width:125px; height:100px; padding:0px;a"/>
                </td>
                <td>
                    <input class="shuZi" onclick="shuZi(this)" class="suZiEnJian" type="button" value="6"style="background-color:greenyellow; border: none; width:125px; height:100px; padding:0px;a"/>
                </td>
                <td>
                    <input class="yunSuanFu" onclick="yunSuan(this)" type="button" value="*" style="background-color: cornflowerblue; border: none; width:125px; height:100px; padding:0px;a"/>
                </td>
            </tr>
            <tr>
                <td>
                    <input class="shuZi" onclick="shuZi(this)" class="suZiEnJian" type="button" value="1" style="background-color:greenyellow; border: none; width:125px; height:100px; padding:0px;a"/>
                </td>
                <td>
                    <input class="shuZi" onclick="shuZi(this)" class="suZiEnJian" type="button" value="2" style="background-color:greenyellow; border: none; width:125px; height:100px; padding:0px;a"/>
                </td>
                <td>
                    <input class="shuZi" onclick="shuZi(this)" class="suZiEnJian" type="button" value="3" style="background-color:greenyellow; border: none; width:125px; height:100px; padding:0px;a"/>
                </td>
                <td>
                    <input class="yunSuanFu" onclick="yunSuan(this)" type="button" value="-" style="background-color: cornflowerblue; border: none; width:125px; height:100px; padding:0px;a"/>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <input class="shuZi" onclick="shuZi(this)" class="suZiEnJian" type="button" value="0" style="background-color:greenyellow; border: none; width:255px; height:100px; padding:0px;a"/>
                </td>
                <td>
                    <input class="shuZi" onclick="shuZi(this)" type="button" value="." style="background-color:greenyellow; border: none; width:125px; height:100px; padding:0px;a"/>
                </td>
                <td>
                    <input class="yunSuanFu" onclick="yunSuan(this)" type="button" value="+" style="background-color: cornflowerblue; border: none; width:125px; height:100px; padding:0px;a"/>
                </td>
            </tr>
        </table>
    </body>
        <script type="text/javascript">
            var dyh = [];
            var jieguo = 0;
            var jsq = [jieguo,dyh];
            var ysf = "";
            var kg = true;
            
            function shuZi(shuZi){
                var int = document.getElementsByClassName("suZiEnJian");
                var pm = document.getElementById("pingMu");
                dyh.push(shuZi.value)
                if (pm.value==jieguo) {
                    pm.value="";
                }
                pm.value+=shuZi.value;
                kg = true;
            }
            
            function yunSuan(yunSuanFu)
            {
                if (kg) {
                    var pm = document.getElementById("pingMu");
                    var zfjg ="" ;
                    for (i=0;i<dyh.length;i++) 
                    {
                        zfjg+=dyh[i];
                    }
                    dyh.splice(0,(dyh.length));
                    
                    switch (ysf){
                        case "+":
                        if (jieguo==0) {
                            jieguo=Number(zfjg);
                        } else{
                            jieguo+=Number(zfjg);
                        }
                        pm.value=jieguo;
                        ysf = "";
                            break;
                        case "-":
                        if (jieguo==0) {
                            jieguo=Number(zfjg);
                        } else{
                            jieguo-=Number(zfjg);
                        }
                        pm.value=jieguo;
                        ysf = "";
                            break;
                        case "*":
                        if (jieguo==0) {
                            jieguo=Number(zfjg);
                        } else{
                            jieguo*=Number(zfjg);
                        }
                        pm.value=jieguo;
                        ysf = "";
                            break;
                        case "/":
                        if (jieguo==0) {
                            jieguo=Number(zfjg);
                        } else{
                            jieguo/=Number(zfjg);
                        }
                        pm.value=jieguo;
                        ysf = "";
                        break;
                        case "=":
                        jieguo=Number(zfjg);
                        pm.value=jieguo;
                        ysf = "";
                            break;
                        default:
                        jieguo=Number(zfjg);
                        pm.value="";
                        ysf = "";
                            break;
                    }
                    ysf = yunSuanFu.value;
                    kg = false;
                }
            }
            
            function shanChu(shanChuFu){
                var pm = document.getElementById("pingMu");
                pm.value="";
                switch (shanChuFu.value){
                    case "←":
                        dyh.pop()
                        for (i=0;i<dyh.length;i++) 
                        {
                            pm.value+=dyh[i];
                        }
                        break;
                    case "CE":
                        break;
                    case "C":
                        dyh.splice(0,(dyh.length));
                        jieguo = 0;
                        ysf = "";
                        break;
                    default:
                        break;
                }
            }
        </script>
</html>

java问题求解!!请高手帮忙啊!我是新手!!
1、新建系统变量JAVA_HOME变量(JAVA_HOME指明JDK安装路径。)设定值为:C:\\Java\\jdk1.6.0_04 2、在系统变量中的path中添加(Path使得系统可以在任何路径下识别java命令。):;%JAVA_HOME%\\bin;%JAVA_HOME%\\jre\\bin;%CATALINA_HOME%\\bin 3、新建系统变量CATALINA_HOME 设定值为:C:\\Java\\apache-t...

求解Java基础选择题。
E.正确 F.应该是正确的,不扣字眼的话,无问题 G.多态指代的是不同类(注意是类,不是对象)拥有的同一种抽象,错误

JAVA题求解
第一个答案为B,思路:4的二次方等于16,第一个if结果为true,执行if内的代码,第二个if结果为false,跳过,第三个16>15,结果为true,执行if内代码后,y=16+1,所以输出y=17.第二个答案为:A,数组内成员以,间隔,而不是;第三个答案:D,思路:编译报错:Test(int a,int b)的构造方...

Java 基础编程题求解,不是很懂
第一种:方式借助于,while循环获取,提示输入内容获取输入值,然后判断如果余数为5结束循环。int i = 0;do{System.out.println("请输入数据边界值:");\/\/获取输入数字Scanner sc = new Scanner(System.in);int s = sc.nextInt();i = s%10;if(i == 5){System.out.println(s);sc.close...

Java题求解
基础知识 1.关于类成员 类的成员就2种:成员变量和成员函数。成员变量又称属性或者字段(java的API中可以见到),成员函数又包括构造函数(又称构造方法,构造器)和普通函数(普通方法)构造函数没有返回类型,函数名与类名必须相同,这是与普通方法的主要区别。拿第一题来说:员工 Employee 类:属性+...

java题求解
1.首先获取一个1-100的整数,代码很简单,要是不会就百度搜索,有很多 2.然后再获取用户输入的数字(一、二步的代码我就不写了)int A = 系统随机出的数字;\/\/获取系统随机出的数字 int B = 用户输入的数字;\/\/获取用户输入的数字 int num =0;\/\/初始化一个变量 \/\/写一个循环,只要A不等于...

java基础 求解比较大小
你好:请参考:public static void main(String[] args) { int[] a = new int[3]; Scanner scan = new Scanner(System.in); for (int i = 0; i < 3; i++) { System.out.print("数字"+(i+1)+":"); a[i] = scan.nextInt();} for (int i = 0; i ...

JAVA题目求解,路过的大神给个帮助!!!
void methodB(){ methodA();}C:错误。假如一个类定义了一个静态方法(使用static关键字修饰)。那么在别的类使用这个方法的时候,可以通过 类名.方法 去使用。如:System.exit(0);D:错误。如果这个类是抽象类(使用abstruct关键字修饰),并且定义的方法也是个抽象方法(同样使用abstruct关键字...

JAVA一个简单问题求解,这里break为什么跳过了两个system.out.println...
当执行了If(t)之后,接着执行break second;break是跳出、终止本层循环,不会再往下执行system.out.println("this wont't execute").break second 的意思是跳出second标签,这样就会执行System.out.println("this is after second block ").

JAVA问题 求解一元二次多项式的根
哥们,已经按你得要求发给你了,给分吧

相似回答