diff --git a/src/java2022spring/Calculator.java b/src/java2022spring/Calculator.java new file mode 100644 index 0000000000000000000000000000000000000000..5c8ca3b04af239a5ceb8db8b7016f94b62bdbea6 --- /dev/null +++ b/src/java2022spring/Calculator.java @@ -0,0 +1,961 @@ +package java2022spring; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.regex.Pattern; +import java.math.BigDecimal; + +public class Calculator extends JFrame implements ActionListener { + String[] keysName={"MC","MS","MR","M+","M-", + "%","C","CE","Back","sin", + "1/x","sqr","x^2","x^3","cos", + "x!","e","e^x","10^x","tan", + "(",")","π","÷","cot", + "7","8","9","×","sec", + "4","5","6","-","csc", + "1","2","3","+","lg", + "+/-","0",".","=","ln", + };//设置按钮名称 + JButton keys[]=new JButton[keysName.length];//设置按钮 + JTextField text = new JTextField("0.0"); + String c=""; + String l; + boolean action; + boolean flag; + String space; + Pattern pattern=Pattern.compile("[+-×%]");//正则表达式 + Pattern reg = Pattern.compile("-?[0-9]+(\\.[0-9]+)?"); + public Calculator() { + JFrame jframe=new JFrame(); + Color color1=new Color(181,181,181); + Color color2=new Color(126,192,238);//"="号颜色 + Color color3=new Color(232,232,232);//背景颜色、功能键和运算符的颜色 + JPanel textPanel=new JPanel();//建立一个画板放文本框 + textPanel.setLayout(new BorderLayout()); + textPanel.add(text);//将文本框放置面板中 + text.setHorizontalAlignment(JTextField.RIGHT);//设置文本框内容靠右 + text.setFont(new Font("楷体",Font.BOLD,35));//设置文本框字体 + text.setEditable(false);//设置文本框不可修改 + text.setBorder(null);//删除文本框的边框 + text.setBackground(color1);//设置文本框的颜色 + JPanel keysPanel=new JPanel(); + keysPanel.setLayout(new GridLayout(9,5,4,5));//设置按钮面板 + keysPanel.setBackground(color1);//设置按钮面板颜色 + jframe.setTitle("常用计算器");//窗口名称 + jframe.setBounds(500, 100, 450, 450);//窗口位置大小 + jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//窗口关闭方式 + jframe.setVisible(true);//窗口可视 + for (int i=0;i=0) { + c=c.substring(0, pos+1); + text.setText(c); + } + else { + c=""; + text.setText("0.0"); + } + }//将最新输入的运算符号后面的数字清空 + else if (label=="sqr") { + String s,a,b; + Boolean d = c.matches("-[0-9]+.*[0-9]*"); + if(c=="") + c="";//若为空串,置为空串 + else if(d==true) { + c="error"; + text.setText(c); + } + else { + int pos=posOfLastOperator(c);//获取最后一个运算符的位置(+-x÷%) + int position=posOfLastOperatorOne(c);//获取"("的位置,实现根号(2+3)即根号5的运算 + if(position>=0) { + String[] p; + a=c.substring(position+1,c.length()-1); + p=operationOne(a);//将"("后面的运算式分开,数字和运算符分开,按算术法则带入outCome方法运算 + String result=outCome(p);//等号运算得出结果 + b=operationTwo(result);//将结果进行根号运算 + StringBuilder builder=new StringBuilder(c); + builder.replace(position,c.length(),b);//将运算结果替换运算式 + c=builder.toString(); + text.setText(c); + }//有括号 + else if(pos>=0) { + a=c.substring(pos+1); + b=operationTwo(a); + StringBuilder builder=new StringBuilder(c); + builder.replace(pos+1,c.length(),b); + c=builder.toString(); + text.setText(c); + }//没括号,只有(+-x÷%) + else { + s=operationTwo(c); + text.setText(s); + c=s; + }//只有数字 + } + }//数字根号运算 + else if(label=="x^2") { + String s,a,b; + if(c=="") + c=""; + else { + int pos=posOfLastOperator(c); + int position=posOfLastOperatorOne(c); + if(position>=0) { + String[] p; + a=c.substring(position+1,c.length()-1); + p=operationOne(a);//将"("后面的运算式分开,数字和运算符分开,按算术法则带入outCome方法运算 + String result=outCome(p);//等号运算得出结果 + b=operationThree(result);//将得出结果进行平方运算 + StringBuilder builder=new StringBuilder(c); + builder.replace(position,c.length(),b);//将运算结果替换运算式 + c=builder.toString(); + text.setText(c); + }//有括号 + else if(pos>=0) { + a=c.substring(pos+1); + b=operationThree(a); + StringBuilder builder=new StringBuilder(c); + builder.replace(pos+1,c.length(),b); + c=builder.toString(); + text.setText(c); + }//没括号,只有(+-x÷%) + else { + s=operationThree(c); + text.setText(s); + c=s; + }//只有数字 + } + }//平方运算 + else if(label=="x^3") { + String s,a,b; + if(c=="") + c=""; + else { + int pos=posOfLastOperator(c); + int position=posOfLastOperatorOne(c); + if(position>=0) { + String[] p; + a=c.substring(position+1,c.length()-1); + p=operationOne(a);//将"("后面的运算式分开,数字和运算符分开,按算术法则带入outCome方法运算 + String result=outCome(p);//等号运算得出结果 + b=operationFive(result);//将得出结果进行平立方运算 + StringBuilder builder=new StringBuilder(c); + builder.replace(position,c.length(),b);//将运算结果替换运算式 + c=builder.toString(); + text.setText(c); + }//有括号 + else if(pos>=0) { + a=c.substring(pos+1); + b=operationFive(a); + StringBuilder builder=new StringBuilder(c); + builder.replace(pos+1,c.length(),b); + c=builder.toString(); + text.setText(c); + }//没括号,只有(+-x÷%) + else { + s=operationFive(c); + text.setText(s); + c=s; + }//只有数字 + } + }//立方运算 + else if(label=="sin"){ + String s,a,b; + if(c=="") + c=""; + else { + int pos=posOfLastOperator(c); + int position=posOfLastOperatorOne(c); + if(position>=0) { + String[] p; + a=c.substring(position+1,c.length()-1); + p=operationOne(a);//将"("后面的运算式分开,数字和运算符分开,按算术法则带入outCome方法运算 + String result=outCome(p);//等号运算得出结果 + double l=Double.parseDouble(result); + double x=Math.sin(l);//计算出sin结果 + s=String.valueOf(x);//将double型结果转换成字符串形式 + StringBuilder builder=new StringBuilder(c); + builder.replace(position,c.length(),s);//将运算结果替换运算式 + c=builder.toString(); + text.setText(c); + }//有括号 + else if(pos>=0) { + a=c.substring(pos+1); + double l=Double.parseDouble(a); + double x=Math.sin(l); + s=String.valueOf(x); + StringBuilder builder=new StringBuilder(c); + builder.replace(pos+1,c.length(),s); + c=builder.toString(); + text.setText(c); + }//没括号,只有(+-x÷%) + else { + double p=Double.parseDouble(c); + double l=Math.sin(p); + s=String.valueOf(l); + text.setText(s); + c=s; + }//只有数字 + } + }//三角函数sin运算 + else if(label=="cos"){ + String s,a,b; + if(c=="") + c=""; + else { + int pos=posOfLastOperator(c); + int position=posOfLastOperatorOne(c); + if(position>=0) { + String[] p; + a=c.substring(position+1,c.length()-1); + p=operationOne(a); + String result=outCome(p); + double l=Double.parseDouble(result); + double x=Math.cos(l); + s=String.valueOf(x); + StringBuilder builder=new StringBuilder(c); + builder.replace(position,c.length(),s); + c=builder.toString(); + text.setText(c); + }//有括号 + else if(pos>=0) { + a=c.substring(pos+1); + double l=Double.parseDouble(a); + double x=Math.cos(l); + s=String.valueOf(x); + StringBuilder builder=new StringBuilder(c); + builder.replace(pos+1,c.length(),s); + c=builder.toString(); + text.setText(c); + }//没括号,只有(+-x÷%) + else { + double p=Double.parseDouble(c); + double l=Math.cos(p); + s=String.valueOf(l); + text.setText(s); + c=s; + }//只有数字 + } + }//三角函数cos运算 + else if(label=="tan"){ + String s,a,b; + if(c=="") + c=""; + else { + int pos=posOfLastOperator(c); + int position=posOfLastOperatorOne(c); + if(position>=0) { + String[] p; + a=c.substring(position+1,c.length()-1); + p=a.split(","); + p=operationOne(a); + String result=outCome(p); + double l=Double.parseDouble(result); + double x=Math.tan(l); + s=String.valueOf(x); + StringBuilder builder=new StringBuilder(c); + builder.replace(position,c.length(),s); + c=builder.toString(); + text.setText(c); + }//有括号 + else if(pos>=0) { + a=c.substring(pos+1); + double l=Double.parseDouble(a); + double x=Math.tan(l); + s=String.valueOf(x); + StringBuilder builder=new StringBuilder(c); + builder.replace(pos+1,c.length(),s); + c=builder.toString(); + text.setText(c); + }//没括号,只有(+-x÷%) + else { + double p=Double.parseDouble(c); + double l=Math.tan(p); + s=String.valueOf(l); + text.setText(s); + c=s; + }//只有数字 + } + }//三角函数tan运算 + else if(label=="cot"){ + String s,a; + if(c=="") + c=""; + else { + int pos=posOfLastOperator(c); + int position=posOfLastOperatorOne(c); + if(position>=0) { + String[] p; + a=c.substring(position+1,c.length()-1); + p=operationOne(a); + String result=outCome(p); + double l=Double.parseDouble(result); + double x=Math.cos(l)/Math.sin(l); + s=String.valueOf(x); + StringBuilder builder=new StringBuilder(c); + builder.replace(position,c.length(),s); + c=builder.toString(); + text.setText(c); + }//有括号 + else if(pos>=0) { + a=c.substring(pos+1); + double l=Double.parseDouble(a); + double x=Math.cos(l)/Math.sin(l); + s=String.valueOf(x); + StringBuilder builder=new StringBuilder(c); + builder.replace(pos+1,c.length(),s); + c=builder.toString(); + text.setText(c); + }//没括号,只有(+-x÷%) + else { + double p=Double.parseDouble(c); + double l=Math.cos(p)/Math.sin(p); + s=String.valueOf(l); + text.setText(s); + c=s; + }//只有数字 + } + }//三角函数cot运算 + else if(label=="sec"){ + String s,a; + if(c=="") + c=""; + else { + int pos=posOfLastOperator(c); + int position=posOfLastOperatorOne(c); + if(position>=0) { + String[] p; + a=c.substring(position+1,c.length()-1); + p=operationOne(a); + String result=outCome(p); + double l=Double.parseDouble(result); + double x=1/Math.cos(l); + s=String.valueOf(x); + StringBuilder builder=new StringBuilder(c); + builder.replace(position,c.length(),s); + c=builder.toString(); + text.setText(c); + }//有括号 + else if(pos>=0) { + a=c.substring(pos+1); + double l=Double.parseDouble(a); + double x=1/Math.cos(l); + s=String.valueOf(x); + StringBuilder builder=new StringBuilder(c); + builder.replace(pos+1,c.length(),s); + c=builder.toString(); + text.setText(c); + }//没括号,只有(+-x÷%) + else { + double p=Double.parseDouble(c); + double l=1/Math.cos(p); + s=String.valueOf(l); + text.setText(s); + c=s; + }//只有数字 + } + }//三角函数sec运算 + else if(label=="csc"){ + String s,a; + if(c=="") + c=""; + else { + int pos=posOfLastOperator(c); + int position=posOfLastOperatorOne(c); + if(position>=0) { + String[] p; + a=c.substring(position+1,c.length()-1); + p=operationOne(a); + String result=outCome(p); + double l=Double.parseDouble(result); + double x=1/Math.sin(l); + s=String.valueOf(x); + StringBuilder builder=new StringBuilder(c); + builder.replace(position,c.length(),s); + c=builder.toString(); + text.setText(c); + }//有括号 + else if(pos>=0) { + a=c.substring(pos+1); + double l=Double.parseDouble(a); + double x=1/Math.sin(l); + s=String.valueOf(x); + StringBuilder builder=new StringBuilder(c); + builder.replace(pos+1,c.length(),s); + c=builder.toString(); + text.setText(c); + }//没括号,只有(+-x÷%) + else { + double p=Double.parseDouble(c); + double l=1/Math.sin(p); + s=String.valueOf(l); + text.setText(s); + c=s; + }//只有数字 + } + }//三角函数csc运算 + else if(label=="10^x") { + String s,a,b; + if(c=="") + c=""; + else { + int pos=posOfLastOperator(c); + int position=posOfLastOperatorOne(c); + if(position>=0) { + String[] p; + a=c.substring(position+1,c.length()-1); + p=operationOne(a); + String result=outCome(p); + b=operationSeven(result); + StringBuilder builder=new StringBuilder(c); + builder.replace(position,c.length(),b); + c=builder.toString(); + text.setText(c); + }//有括号 + else if(pos>=0) { + a=c.substring(pos+1); + b=operationSeven(a); + StringBuilder builder=new StringBuilder(c); + builder.replace(pos+1,c.length(),b); + c=builder.toString(); + text.setText(c); + }//没括号,只有(+-x÷%) + else { + s=operationSeven(c); + text.setText(s); + c=s; + }//只有数字 + } + }//10^x运算 + else if(label=="e^x") { + String s,a,b; + if(c=="") + c=""; + else { + int pos=posOfLastOperator(c); + int position=posOfLastOperatorOne(c); + if(position>=0) { + String[] p; + a=c.substring(position+1,c.length()-1); + p=operationOne(a); + String result=outCome(p); + b=operationEight(result); + StringBuilder builder=new StringBuilder(c); + builder.replace(position,c.length(),b); + c=builder.toString(); + text.setText(c); + }//有括号 + else if(pos>=0) { + a=c.substring(pos+1); + b=operationEight(a); + StringBuilder builder=new StringBuilder(c); + builder.replace(pos+1,c.length(),b); + c=builder.toString(); + text.setText(c); + }//没括号,只有(+-x÷%) + else { + s=operationEight(c); + text.setText(s); + c=s; + }//只有数字 + } + }//e^x运算 + else if(label=="1/x"){ + String s,a,b; + if(c=="") + c=""; + else { + int pos=posOfLastOperator(c); + int position=posOfLastOperatorOne(c); + if(position>=0) { + String[] p; + a=c.substring(position+1,c.length()-1); + p=operationOne(a); + String result=outCome(p); + b=operationFour(result);//0的倒数置为错误error + StringBuilder builder=new StringBuilder(c); + builder.replace(position,c.length(),b); + c=builder.toString(); + text.setText(c); + }//有括号 + else if(pos>=0) { + a=c.substring(pos+1); + b=operationFour(a); + StringBuilder builder=new StringBuilder(c); + builder.replace(pos+1,c.length(),b); + c=builder.toString(); + text.setText(c); + }//没括号,只有(+-x÷%) + else { + s=operationFour(c); + text.setText(s); + c=s; + }//只有数字 + } + }//倒数运算 + else if(label=="lg"){ + String s,a,b; + if(c=="") + c=""; + else { + int pos=posOfLastOperator(c); + int position=posOfLastOperatorOne(c); + if(position>=0) { + String[] p; + a=c.substring(position+1,c.length()-1); + p=a.split(","); + p=operationOne(a); + String result=outCome(p); + double l=Double.parseDouble(result); + double x=Math.log10(l); + s=String.valueOf(x); + StringBuilder builder=new StringBuilder(c); + builder.replace(position,c.length(),s); + c=builder.toString(); + text.setText(c); + }//有括号 + else if(pos>=0) { + a=c.substring(pos+1); + double l=Double.parseDouble(a); + double x=Math.log10(l); + s=String.valueOf(x); + StringBuilder builder=new StringBuilder(c); + builder.replace(pos+1,c.length(),s); + c=builder.toString(); + text.setText(c); + }//没括号,只有(+-x÷%) + else { + double p=Double.parseDouble(c); + double l=Math.log10(p); + s=String.valueOf(l); + text.setText(s); + c=s; + }//只有数字 + } + }//lg运算 + else if(label=="ln"){ + String s,a; + if(c=="") + c=""; + else { + int pos=posOfLastOperator(c); + int position=posOfLastOperatorOne(c); + if(position>=0) { + String[] p; + a=c.substring(position+1,c.length()-1); + p=operationOne(a); + String result=outCome(p); + double l=Double.parseDouble(result); + double x=Math.log(l); + s=String.valueOf(x); + StringBuilder builder=new StringBuilder(c); + builder.replace(position,c.length(),s); + c=builder.toString(); + text.setText(c); + }//有括号 + else if(pos>=0) { + a=c.substring(pos+1); + double l=Double.parseDouble(a); + double x=Math.log(l); + s=String.valueOf(x); + StringBuilder builder=new StringBuilder(c); + builder.replace(pos+1,c.length(),s); + c=builder.toString(); + text.setText(c); + }//没括号,只有(+-x÷%) + else { + double p=Double.parseDouble(c); + double l=Math.log(p); + s=String.valueOf(l); + text.setText(s); + c=s; + }//只有数字 + } + }//ln运算 + else if(label=="x!"){ + String s,a,b; + Boolean d = c.matches("-[0-9]+.*[0-9]*"); + if(c=="") + c=""; + else if(d==true) { + c="error"; + text.setText(c); + } + else { + int pos=posOfLastOperator(c); + int position=posOfLastOperatorOne(c); + if(position>=0) { + String[] p; + a=c.substring(position+1,c.length()-1); + p=operationOne(a); + String result=outCome(p); + b=operationSix(result); + StringBuilder builder=new StringBuilder(c); + builder.replace(position,c.length(),b); + c=builder.toString(); + text.setText(c); + }//有括号 + else if(pos>=0) { + a=c.substring(pos+1); + b=operationSix(a); + StringBuilder builder=new StringBuilder(c); + builder.replace(pos+1,c.length(),b); + c=builder.toString(); + text.setText(c); + }//没括号,只有(+-x÷%) + else { + s=operationSix(c); + text.setText(s); + c=s; + }//只有数字 + } + }//x!运算 + else if (label=="e") { + String s=String.valueOf(2.718281828459); + c=c+s; + text.setText(c); + }//得出e的结果 + else if (label=="π") { + String s=String.valueOf(3.141592653589); + c=c+s; + text.setText(c); + }//得出π的结果 + else if(label=="+/-") { + if(reg.matcher(c).matches()) { + StringBuffer c1=new StringBuffer(c); + c1.insert(0, "-"); + c=c1.toString(); + } + text.setText(c); + }//正负号运算 + else { + c=c+label; + text.setText(c); + } + } +//将算术式拆分成数组,运用栈的相关知识,得出运算优先级()、%、×、÷、+、-,方法operationOne和Outcome的计算原理(有关中缀表达式转后缀表达式,后缀表达式计算)借鉴CSDN博客qq_4139880 + String []operationOne(String str) { + String s=""; + char a[]=new char[200];//栈 + String outcome[]=new String[200];//后缀表达式字符串组 + int top=-1,j=0; + //遍历中缀表达式 + for (int i=0;i=0) { + s="";//清空字符串 + for (;i=0;i++) { + s=s+str.charAt(i); + } + i--; + outcome[j]=s;//数字字符直接加入后缀表达式 + j++; + } + else if ("(".indexOf(str.charAt(i))>=0)//当遇到左括号 + { + top++; + a[top]=str.charAt(i);//左括号入栈 + } + else if (")".indexOf(str.charAt(i))>=0) //当遇到右括号 + { + for (;;) { + if (a[top]!='(') { + outcome[j]=a[top]+"";//栈顶元素出栈 + j++; + top--; + } + else { + top--;//删除栈顶的左括号 + break; + } + } + } + else if ("×%÷".indexOf(str.charAt(i))>=0) //遇到高优先级运算符 + { + if (top==-1) //若栈为空直接入栈 + { + top++; + a[top]=str.charAt(i); + } + else { + if ("×%÷".indexOf(a[top])>=0) { + outcome[j]=a[top]+"";//栈顶元素出栈进入后缀表达式 + j++; + a[top]=str.charAt(i); + } + else if ("(".indexOf(a[top])>=0) { + top++; + a[top]=str.charAt(i); + } + else if ("+-".indexOf(a[top])>=0) { + top++; + a[top]=str.charAt(i); + } + } + } + else if ("+-".indexOf(str.charAt(i))>=0) //遇到低优先级运算符 + { + if (top==-1)//栈为空直接入栈 + { + top++; + a[top]=str.charAt(i); + } + else { + if ("%×÷".indexOf(a[top])>=0) { + outcome[j]=a[top]+""; + j++; + a[top]=str.charAt(i); + } + else if ("(".indexOf(a[top])>=0) { + top++; + a[top]=str.charAt(i); + } + else if ("+-".indexOf(a[top])>=0) { + outcome[j]=a[top]+""; + j++; + a[top]=str.charAt(i); + } + } + + } + } + for (;top!=-1;) //遍历结束后将栈中剩余元素依次出栈进入后缀表达式 + { + outcome[j]=a[top]+""; + j++; + top--; + } + return outcome; + } + public String outCome(String str[]) { + String result[]=new String[200]; + int Top=-1; + for (int i=0;str[i]!=null;i++) //遍历后缀表达式 + { + if (reg.matcher(str[i]).matches()) { //数字字符进栈 + Top++; + result[Top]=str[i]; + } + else if ("+-×%÷".indexOf(str[i])>=0) { + double x,y,n; + x=Double.parseDouble(result[Top]); + Top--; + y=Double.parseDouble(result[Top]); + Top--; + if ("-".indexOf(str[i])>=0) { + n=y-x; + Top++; + result[Top]=String.valueOf(n);//将运算结果重新入栈 + } + else if ("+".indexOf(str[i])>=0) { + n=y+x; + Top++; + result[Top]=String.valueOf(n); + } + else if ("×".indexOf(str[i])>=0) { + n=y*x; + Top++; + result[Top]=String.valueOf(n); + } + else if ("÷".indexOf(str[i])>=0) { + if (x==0) { + String s="error"; + return s; + } + else { + n=y/x; + Top++; + result[Top]=String.valueOf(n); + } + } + if ("%".indexOf(str[i])>=0) { + if (x==0) { + String s="error"; + return s; + } + else { + n=y%x; + Top++; + result[Top]=String.valueOf(n); + } + } + } + } + double z=Double.parseDouble(result[Top]); + String zz=String.format("%.1f", z); + result[Top]=zz; + return result[Top]; + } + + public String operationTwo(String str) { + String result; + double a=Double.parseDouble(str),b=0; + b=Math.sqrt(a); + result=String.valueOf(b); + return result; + }//根号运算 + + public String operationThree(String str) { + String result; + double a=Double.parseDouble(str),b=0; + b=Math.pow(a, 2); + result=String.valueOf(b); + return result; + }//平方运算 + + public String operationFour(String str) { + String result; + double a=Double.parseDouble(str),b=0; + String s; + if(a==0.0) { + s="error"; + return s; + } + else { + b=1/a; + result=String.valueOf(b); + return result; + } + }//倒数运算 + + public String operationFive(String str) { + String result; + double a=Double.parseDouble(str),b=0; + b=Math.pow(a, 3); + result=String.valueOf(b); + return result; + }//立方运算 + + public String operationSix(String str) { + int ee; + double p=Double.parseDouble(str); + double result=p; + int c=1; + for(ee=1;ee<=result;ee++) + { + c=c*ee; + p=c; + } + String s=String.valueOf(p); + return s; + }//n!运算 + + public String operationSeven(String str) + { + String result; + double a=Double.parseDouble(str),b=0; + b=Math.pow(10,a); + result=String.valueOf(b); + return result; + }//10^x运算 + + public String operationEight(String str) + { + String result; + double a=Double.parseDouble(str),b=0; + b=Math.pow(2.718281828459,a); + result=String.valueOf(b); + return result; + }//e^x运算 + + public int posOfLastOperator(String s) { + for(int i=s.length()-1;i>=0;i--) + { + if(isOperator(s.charAt(i))) + return i; + } + return -1; + }//获取传入字符串最后一个运算符的位置 + + public boolean isOperator(char c) { + return (c=='+')||(c=='-')||(c=='×')||(c=='÷')||(c=='%'); + }//判断是否为+-x÷%符号 + + public int posOfLastOperatorOne(String s) { + for(int i=s.length()-1;i>=0;i--) + { + if(isOperatorOne(s.charAt(i))) + return i; + } + return -1; + }//获取传入字符串中括号的位置 + + public boolean isOperatorOne(char c) { + return c=='('; + } +} diff --git a/src/java2022spring/MainClass.java b/src/java2022spring/MainClass.java new file mode 100644 index 0000000000000000000000000000000000000000..904a46841d1aec79abbb76d90188f4b7b14a0b42 --- /dev/null +++ b/src/java2022spring/MainClass.java @@ -0,0 +1,9 @@ +package java2022spring; + + +public class MainClass{ +public static void main(String arg[]) +{ + new Calculator(); +} +} \ No newline at end of file diff --git a/src/java2022spring/Test.java b/src/java2022spring/Test.java deleted file mode 100644 index 24deb29bfc0e5f50fdedcd21b504e77b529d48b6..0000000000000000000000000000000000000000 --- a/src/java2022spring/Test.java +++ /dev/null @@ -1,7 +0,0 @@ -package java2022spring; - -public class Test { - public static void main(String[] args) { - System.out.println("Hello world!"); - } -}