第二次第一题

master
cwx 11 months ago
parent 101365d90b
commit f5ca52837b

@ -2,9 +2,8 @@
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/First_Jisuan/First_Jisuan.iml" filepath="$PROJECT_DIR$/First_Jisuan/First_Jisuan.iml" />
<module fileurl="file://$PROJECT_DIR$/First_Jisuan1/First_Jisuan1.iml" filepath="$PROJECT_DIR$/First_Jisuan1/First_Jisuan1.iml" />
<module fileurl="file://$PROJECT_DIR$/Second_Jinzhi/Second_Jinzhi.iml" filepath="$PROJECT_DIR$/Second_Jinzhi/Second_Jinzhi.iml" />
<module fileurl="file://$PROJECT_DIR$/test6298.iml" filepath="$PROJECT_DIR$/test6298.iml" />
</modules>
</component>
</project>

@ -2,5 +2,6 @@
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="$PROJECT_DIR$/First_Jisuan1" vcs="Git" />
</component>
</project>

@ -4,15 +4,12 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="240004e1-ef35-41dc-944d-01a893c69670" name="Changes" comment="第二修改">
<list default="true" id="240004e1-ef35-41dc-944d-01a893c69670" name="Changes" comment="第二次第一题">
<change beforePath="$PROJECT_DIR$/.idea/modules.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/vcs.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/vcs.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/jinzhi/Second_Jinzhi.iml" beforeDir="false" afterPath="$PROJECT_DIR$/Second_Jinzhi/Second_Jinzhi.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/jinzhi/src/jinzhi2.java" beforeDir="false" afterPath="$PROJECT_DIR$/Second_Jinzhi/src/jinzhi2.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/jisuan/First_Jisuan.iml" beforeDir="false" afterPath="$PROJECT_DIR$/First_Jisuan/First_Jisuan.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/jisuan/src/Main.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/jisuan/src/jisuan1.java" beforeDir="false" afterPath="$PROJECT_DIR$/First_Jisuan/src/jisuan1.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/First_Jisuan/First_Jisuan.iml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/First_Jisuan/src/jisuan1.java" beforeDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -38,7 +35,7 @@
<entry key="$PROJECT_DIR$" value="main" />
</map>
</option>
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/First_Jisuan1" />
</component>
<component name="ProjectColorInfo">{
&quot;associatedIndex&quot;: 5
@ -55,15 +52,16 @@
"keyToString": {
"Application.JinZhi.executor": "Run",
"Application.jinzhi2.executor": "Run",
"Application.jisuan1.executor": "Run",
"Application.mm.executor": "Run",
"RunOnceActivity.ShowReadmeOnStart": "true",
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
"git-widget-placeholder": "master",
"kotlin-language-version-configured": "true",
"last_opened_file_path": "C:/pannew"
"last_opened_file_path": "D:/Git/chen/pan/First_Jisuan1"
}
}]]></component>
<component name="RunManager" selected="Application.jinzhi2">
<component name="RunManager" selected="Application.jisuan1">
<configuration name="JinZhi" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="JinZhi" />
<module name="Second_Jinzhi" />
@ -78,8 +76,29 @@
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="jisuan1" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="jisuan1" />
<module name="First_Jisuan1" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration default="true" type="JetRunConfigurationType">
<module name="First_Jisuan1" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration default="true" type="KotlinStandaloneScriptRunConfigurationType">
<module name="First_Jisuan1" />
<option name="filePath" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<recent_temporary>
<list>
<item itemvalue="Application.jisuan1" />
<item itemvalue="Application.jinzhi2" />
<item itemvalue="Application.JinZhi" />
</list>
@ -102,11 +121,28 @@
<option name="project" value="LOCAL" />
<updated>1729153009506</updated>
</task>
<option name="localTasksCounter" value="2" />
<task id="LOCAL-00002" summary="第二次第一题">
<option name="closed" value="true" />
<created>1729154083758</created>
<option name="number" value="00002" />
<option name="presentableId" value="LOCAL-00002" />
<option name="project" value="LOCAL" />
<updated>1729154083758</updated>
</task>
<task id="LOCAL-00003" summary="第二次第一题">
<option name="closed" value="true" />
<created>1729154360262</created>
<option name="number" value="00003" />
<option name="presentableId" value="LOCAL-00003" />
<option name="project" value="LOCAL" />
<updated>1729154360262</updated>
</task>
<option name="localTasksCounter" value="4" />
<servers />
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="第二题修改" />
<option name="LAST_COMMIT_MESSAGE" value="第二题修改" />
<MESSAGE value="第二次第一题" />
<option name="LAST_COMMIT_MESSAGE" value="第二次第一题" />
</component>
</project>

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -1,211 +0,0 @@
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class jisuan1{
public static void main(String[] args) {
JS win=new JS();
}
}
class JS extends JFrame implements ActionListener{
private StringBuilder sBuilder = new StringBuilder();
JTextArea text=new JTextArea();
double a,b;
Double sum;
int i;
public JS()
{
setBounds(100,100,400,400);
setTitle("计算器");
this.setLayout(new BorderLayout());
JPanel p1=new JPanel();
JPanel p2=new JPanel();
text.setPreferredSize(new Dimension (370,60));
p2.setLayout(new FlowLayout());
p1.add(text);
this.add(p1,BorderLayout.NORTH);
p2.setLayout(new GridLayout(5,4));
JButton button[]=new JButton[20];
button[0]=new JButton("C");
button[1]=new JButton(" ");
button[2]=new JButton("%");
button[3]=new JButton("÷");
button[4]=new JButton("7");
button[5]=new JButton("8");
button[6]=new JButton("9");
button[7]=new JButton("x");
button[8]=new JButton("4");
button[9]=new JButton("5");
button[10]=new JButton("6");
button[11]=new JButton("—");
button[12]=new JButton("1");
button[13]=new JButton("2");
button[14]=new JButton("3");
button[15]=new JButton("+");
button[16]=new JButton("");
button[17]=new JButton("0");
button[18]=new JButton(".");
button[19]=new JButton("=");
for(int i=0;i<button.length;i++ )
p2.add(button[i]);
p2.add(button[19]);
add(p2,BorderLayout.CENTER);
for(int i=0;i<button.length;i++)
button[i].addActionListener(this);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent e)
{
String lab=e.getActionCommand();
if(lab.equals("0"))
{
sBuilder.append("0");
text.setText(sBuilder.toString());
}
else if(lab.equals("1"))
{
sBuilder.append("1");
text.setText(sBuilder.toString());
}
else if(lab.equals("2"))
{
sBuilder.append("2");
text.setText(sBuilder.toString());
}
else if(lab.equals("3"))
{
sBuilder.append("3");
text.setText(sBuilder.toString());
}
else if(lab.equals("4"))
{
sBuilder.append("4");
text.setText(sBuilder.toString());
}
else if(lab.equals("5"))
{
sBuilder.append("5");
text.setText(sBuilder.toString());
}
else if(lab.equals("6"))
{
sBuilder.append("6");
text.setText(sBuilder.toString());
}
else if(lab.equals("7"))
{
sBuilder.append("7");
text.setText(sBuilder.toString());
}
else if(lab.equals("8"))
{
sBuilder.append("8");
text.setText(sBuilder.toString());
}
else if(lab.equals("9"))
{
sBuilder.append("9");
text.setText(sBuilder.toString());
}
else if(lab.equals("C"))
{
sBuilder = new StringBuilder();
text.setText(sBuilder.toString());
}
else if(lab.equals("."))
{
sBuilder.append(".");
text.setText(sBuilder.toString());
}
else if(lab.equals("+"))
{
a = Double.parseDouble(sBuilder.toString());
i=0;
sBuilder = new StringBuilder();
text.setText("+");
}
else if(lab.equals("—"))
{
a = Double.parseDouble(sBuilder.toString());
i=1;
sBuilder = new StringBuilder();
text.setText("—");
}
else if(lab.equals("x"))
{
a = Double.parseDouble(sBuilder.toString());
i=2;
sBuilder = new StringBuilder();
text.setText("x");
}
else if(lab.equals("÷"))
{
i=3;
a = Double.parseDouble(sBuilder.toString());
sBuilder = new StringBuilder();
text.setText("÷");
}
else if(lab.equals("%"))
{
a = Double.parseDouble(sBuilder.toString());
i=4;
sBuilder = new StringBuilder();
text.setText("%");
}
else if(lab.equals("="))
{
b = Double.parseDouble(sBuilder.toString());
if (i == 0)
{
sum=a+b;
text.setText(sum.toString());
sBuilder = new StringBuilder();
sBuilder.append(sum);
}
else if (i == 1)
{
sum = a - b;
text.setText(sum.toString());
sBuilder = new StringBuilder();
sBuilder.append(sum);
}
else if (i == 2)
{
sum = a * b;
text.setText(sum.toString());
sBuilder = new StringBuilder();
sBuilder.append(sum);
}
else if (i == 3)
{
sum = a / b;
text.setText(sum.toString());
sBuilder = new StringBuilder();
sBuilder.append(sum);
}
else if (i == 4)
{
sum=a % b;
int m=(int)a;
int n=(int)b;
sum=(double)m % n;
text.setText(sum.toString());
sBuilder = new StringBuilder();
sBuilder.append(sum);
}
else
text.setText(sBuilder.toString());
}
}
}
Loading…
Cancel
Save