关于计算7参数java代码的信息

java随机输出7个数的代码问题!

这个one_num是一个结点,为了continue one_num;

站在用户的角度思考问题,与客户深入沟通,找到东丽网站设计与东丽网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:成都网站建设、网站制作、企业官网、英文网站、手机端网站、网站推广、域名申请、虚拟空间、企业邮箱。业务覆盖东丽地区。

这个语句,也就是说,如果if成立了,程序跳到这来。

要不然的话continue只是结束本次循环,在本程序中也主浊结束了for,而不能跳到while外面。

编写Java程序,计算10到100之间7倍数的和?

public class Sum {

public static void main(String[] args) {

int total = 100;

int sum = 0;

for (int i = 10; i = total; i++) {

if (i % 7 == 0) {

sum = sum + i;

} else {

continue;

}

}

System.out.println("Result = " + sum);

}

}

如何用java程序 求0.1的7次方

在Math类中pow的声明:

public static double pow(double a, double b)

参数:

a - 底数。

b - 指数。

返回:

值 a的b次幂

求0.1的7次方

Math.pow(0.1,7);

注意7如果是int的,会自运转为double型的,返回结果为double型的.

你写的没有错,其实这样Math.pow(d1, d2)是最好的输写方法,最好不要直接将数做为参数传给方法,不然后期的维就费劲了.

不还注意一些小点,类名的第一个字母最好为大写的.而且是能够表达这个类的意思的,功能的.

返回第一个参数的第二个参数次幂的值。特殊情况是:

如果第二个参数是正零或负零,那么结果是 1.0。

如果第二个参数是 1.0,那么结果与第一个参数相同。

如果第二个参数是 NaN,那么结果是 NaN。

如果第一个参数是 NaN,第二个参数是非零,那么结果是 NaN。

如果

第一个参数的绝对值大于 1,并且第二个参数是正无穷大,或者

第一个参数的绝对值小于 1,并且第二个参数是负无穷大,

那么结果是正无穷大。

如果

第一个参数的绝对值大于 1,并且第二个参数是负无穷大,或者

第一个参数的绝对值小于 1,并且第二个参数是正无穷大,

那么结果是正零。

如果第一个参数的绝对值等于1,并且第二个参数是无穷大,那么结果是 NaN。

如果

第一个参数是正零,并且第二个参数大于零,或者

第一个参数是正无穷大,并且第二个参数小于零,

那么结果是正零。

如果

第一个参数是正零,并且第二个参数小于零,或者

第一个参数是正无穷大,并且第二个参数大于零,

那么结果是正无穷大。

如果

如果第一个参数是负零,并且第二个参数大于零但不是有限的奇数整数,或者

第一个参数是负无穷大,并且第二个参数小于零但不是有限的奇数整数,

那么结果是正零。

如果

第一个参数是负零,并且第二个参数是正的有限奇数整数,或者

第一个参数是负无穷大,并且第二个参数是负的有限奇数整数,

那么结果是负零。

如果

如果第一个参数是负零,并且第二个参数小于零但不是有限的奇数整数,或者

第一个参数是负无穷大,并且第二个参数大于零但不是有限的奇数整数,

那么结果是正无穷大。

如果

第一个参数是负零,并且第二个参数是负的有限奇数整数,或者

第一个参数是负无穷大,并且第二个参数是正的有限奇数整数,

那么结果是负无穷大。

如果第一个参数是小于零的有限值,

并且第二个参数是有限的偶数整数,那么结果等于第一个参数的绝对值的第二个参数次幂的结果。

如果第二个参数是有限的奇数整数,那么结果等于第一个参数绝对值的第二个参数次幂的结果的负数。

如果第二个参数是有限的非整数值,那么结果是 NaN。

如果两个参数都是整数,并且结果可以表示为 double 值,那么该结果恰好等于第一个参数的第二个参数次幂的算术结果。

(在前面的描述中,当且仅当浮点数为有限值并且是方法 ceil 的定点数,或者是方法 floor 的定点数时,才可以认为浮点值是整数。当且仅当将方法应用到该值的结果等于该值时,该值才是带有一个参数的某个方法的定点值。)

计算结果必须在准确结果的 1 ulp 范围内。结果必须具有半单调性。

java编一个计算器的代码

界面漂亮堪比系统自带计算器,功能完美加减乘除开平方等等全部具备,还有清零按钮,小数点的使用,连加连乘功能完全参考系统官方计算器经过长期调试改进而成,马上拷贝代码拿去试试看吧,绝不后悔!

代码如下:

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import java.util.*;

public class Counter {

public static void main(String[] args) {

CounterFrame frame = new CounterFrame();

frame.show();

}

}

class CounterFrame extends JFrame {

public CounterFrame() {

JMenuBar menuBar = new JMenuBar();

JMenu menuFile = new JMenu();

JMenu menuFile1 = new JMenu();

JMenu menuFile2 = new JMenu();

JMenu menuFile3 = new JMenu();

JMenuItem menuFileExit = new JMenuItem();

menuFile.setText("文件");

menuFile1.setText("编辑");

menuFile2.setText("查看");

menuFile3.setText("帮助");

menuFileExit.setText("退出");

menuFileExit.addActionListener

(

new ActionListener() {

public void actionPerformed(ActionEvent e) {

CounterFrame.this.windowClosed();

}

}

);

menuFile.add(menuFileExit);

menuBar.add(menuFile);

menuBar.add(menuFile1);

menuBar.add(menuFile2);

menuBar.add(menuFile3);

setTitle("计算器");

setJMenuBar(menuBar);

setSize(new Dimension(400, 280));

this.getContentPane().add(new Allpanel());

this.addWindowListener

(

new WindowAdapter() {

public void windowClosing(WindowEvent e) {

CounterFrame.this.windowClosed();

}

}

);

}

protected void windowClosed() {

System.exit(0);

}

}

class Tool {

public static Tool instance;

private JTextField field;

private Tool() {

this.field=new JTextField(30);

this.field.setHorizontalAlignment(JTextField.RIGHT);

}

public static Tool getinstance()

{

if(instance==null)

{

instance=new Tool();

}

return instance;

}

public JTextField getfield()

{

return (this.field);

}

}

class Allpanel extends JPanel {

public Allpanel() {

this.setLayout(new BorderLayout(0,7));

Northpanel np=new Northpanel();

Centerpanel cp=new Centerpanel();

this.add(np,BorderLayout.NORTH);

this.add(cp,BorderLayout.CENTER);

}

}

class Centercenter extends JPanel {

static Vector Vec=new Vector();

static Vector vc=new Vector();

static Vector vc1=new Vector();

static Vector vc2=new Vector();

static Vector vc3=new Vector();

static String begin="yes";

static double add;

static double jq;

static double cs;

static double cq;

static double dy;

static String jg;

static String what;

static double tool=0;

static String to="yes";

/**

* Method Centercenter

*

*

*/

public Centercenter() {

// TODO: Add your code here

final JTextField text=Tool.getinstance().getfield();

this.setLayout(new GridLayout(4,5,3,3));

String arg[] ={"7","8","9","/","sqrt","4","5","6","*","%","1","2","3","-","1/x","0","+/-",".","+","="};

for(int i=0;i20;i++)

{

final JButton b=new JButton(arg[i]);

//this.add(new JButton(arg[i]));

this.add(b);

if(i==0||i==1||i==2||i==5||i==6||i==7||i==10||i==11||i==12||i==15)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String mark=b.getText();

String ma=text.getText();

if(vc3.contains("v3"))

{

text.setText("0."+mark);

vc3.clear();

}

else if(vc.contains("a"))

{

if(vc2.contains("v2"))

{

text.setText("0."+mark);

vc.clear();

vc2.clear();

}

else

{

text.setText(mark);

vc.clear();

Vec.clear();

Vec.add(mark);

}

}

else

{

text.setText(ma.trim()+mark);

Vec.add(mark);

}

begin="no";

to="yes";

}

});

}

if(i==17)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String mar=b.getText();

String m=text.getText();

if("yes".equals(begin))

{

vc3.add("v3");

}

if(vc1.contains("v1"))

{

vc2.add("v2");

vc1.clear();

}

if(!Vec.contains(".")!vc.contains("a"))

{

text.setText(m.trim()+mar);

Vec.add(".");

}

}

});

}

if(i==18)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String ma=text.getText();

add=Double.parseDouble(ma);

if(what==null)

{

tool=add;

what="add";

}

else

{

tool=tool+add;

text.setText(String.valueOf((tool)));

}

vc.add("a");

vc1.add("v1");

to="+";

}

});

}

if(i==13)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String ma=text.getText();

jq=Double.parseDouble(ma);

if(what==null)

{

tool=jq;

what="jq";

}

else

{

tool=tool-jq;

text.setText(String.valueOf((tool)));

}

vc.add("a");

vc1.add("v1");

to="-";

}

});

}

if(i==3)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String ma=text.getText();

cq=Double.parseDouble(ma);

if(what==null)

{

tool=cq;

what="cq";

}

else

{

tool=tool/cq;

text.setText(String.valueOf((tool)));

}

vc.add("a");

vc1.add("v1");

to="/";

}

});

}

if(i==4)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String ma=text.getText();

cq=Double.parseDouble(ma);

text.setText(String.valueOf(Math.sqrt(cq)));

}

});

}

if(i==8)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String ma=text.getText();

cs=Double.parseDouble(ma);

if(what==null)

{

tool=cs;

what="cs";

}

else

{

tool=tool*cs;

text.setText(String.valueOf((tool)));

}

vc.add("a");

vc1.add("v1");

to="*";

}

});

}

if(i==19)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String ma=text.getText();

dy=Double.parseDouble(ma);

if(what=="add")

{

jg=String.valueOf((tool+dy));

}

if(what=="jq")

{

jg=String.valueOf((tool-dy));

}

if(what=="cs")

{

jg=String.valueOf((tool*dy));

}

if(what=="cq")

{

jg=String.valueOf((tool/dy));

}

if(what==null)

{

if(to=="+")

{

tool=add;

jg=String.valueOf(tool+dy);

}

else if(to=="-")

{

tool=jq;

jg=String.valueOf(dy-tool);

}

else if(to=="*")

{

tool=cs;

jg=String.valueOf(dy*tool);

}

else if(to=="/")

{

tool=cq;

jg=String.valueOf(dy/tool);

}

else

{

jg=String.valueOf(dy);

}

}

text.setText(jg);

Vec.clear();

Vec.add(".");

vc.add("a");

vc1.add("v1");

what=null;

tool=0;

}

});

}

}

}

}

class Centernorth extends JPanel {

public Centernorth() {

final JTextField text=Tool.getinstance().getfield();

JButton jb1=new JButton("Backspace");

JButton jb2=new JButton(" CE ");

JButton jb3=new JButton(" C ");

this.add(jb1);

this.add(jb2);

this.add(jb3);

jb1.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e)

{

String back=Tool.getinstance().getfield().getText();

text.setText(backmethod(back));

Centercenter.Vec.remove(Centercenter.Vec.size()-1);

}

});

jb3.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e)

{

text.setText("0.");

Centercenter.Vec.clear();

Centercenter.Vec.add(".");

Centercenter.vc.add("a");

Centercenter.begin="yes";

Centercenter.vc1.clear();

Centercenter.what=null;

Centercenter.tool=0;

}

});

}

public String backmethod(String str)

{

return str.substring(0,str.length()-1);

}

}

class Centerpanel extends JPanel {

public Centerpanel() {

this.setLayout(new BorderLayout(8,7));

Centernorth cn=new Centernorth();

Centercenter cc=new Centercenter();

Centerwest cw=new Centerwest();

this.add(cn,BorderLayout.NORTH);

this.add(cc,BorderLayout.CENTER);

this.add(cw,BorderLayout.WEST);

}

}

class Centerwest extends JPanel {

public Centerwest() {

this.setLayout(new GridLayout(4,1,3,3));

this.add(new JButton("MC"));

this.add(new JButton("MR"));

this.add(new JButton("MS"));

this.add(new JButton("M+"));

}

}

class Northpanel extends JPanel {

private JTextField tf;

public Northpanel() {

tf=Tool.getinstance().getfield();

this.add(tf);

}

}

---------------------------------------------------------------------------

=============《按你要求特意后改过的最简单功能的代码如下》========================

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import java.util.*;

public class Counter2 {

public static void main(String[] args) {

CounterFrame frame = new CounterFrame();

frame.show();

}

}

class CounterFrame extends JFrame {

public CounterFrame() {

setTitle("计算器");

setSize(new Dimension(400, 280));

this.getContentPane().add(new Allpanel());

this.addWindowListener

(

new WindowAdapter() {

public void windowClosing(WindowEvent e) {

CounterFrame.this.windowClosed();

}

}

);

}

protected void windowClosed() {

System.exit(0);

}

}

class Tool {

public static Tool instance;

private JTextField field;

private Tool() {

this.field=new JTextField(30);

this.field.setHorizontalAlignment(JTextField.RIGHT);

}

public static Tool getinstance()

{

if(instance==null)

{

instance=new Tool();

}

return instance;

}

public JTextField getfield()

{

return (this.field);

}

}

class Allpanel extends JPanel {

public Allpanel() {

this.setLayout(new BorderLayout(0,7));

Northpanel np=new Northpanel();

Centerpanel cp=new Centerpanel();

this.add(np,BorderLayout.NORTH);

this.add(cp,BorderLayout.CENTER);

}

}

class Centercenter extends JPanel {

static Vector Vec=new Vector();

static Vector vc=new Vector();

static Vector vc1=new Vector();

static Vector vc2=new Vector();

static Vector vc3=new Vector();

static String begin="yes";

static double add;

static double jq;

static double cs;

static double cq;

static double dy;

static String jg;

static String what;

static double tool=0;

static String to="yes";

/**

* Method Centercenter

*

*

*/

public Centercenter() {

// TODO: Add your code here

final JTextField text=Tool.getinstance().getfield();

this.setLayout(new GridLayout(4,5,3,3));

String arg[] ={"7","8","9","/","4","5","6","*","1","2","3","-","0","=",".","+"};

for(int i=0;i16;i++)

{

final JButton b=new JButton(arg[i]);

//this.add(new JButton(arg[i]));

this.add(b);

if(i==0||i==1||i==2||i==4||i==5||i==6||i==8||i==9||i==10||i==12)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String mark=b.getText();

String ma=text.getText();

if(vc3.contains("v3"))

{

text.setText("0."+mark);

vc3.clear();

}

else if(vc.contains("a"))

{

if(vc2.contains("v2"))

{

text.setText("0."+mark);

vc.clear();

vc2.clear();

}

else

{

text.setText(mark);

vc.clear();

Vec.clear();

Vec.add(mark);

}

}

else

{

text.setText(ma.trim()+mark);

Vec.add(mark);

}

begin="no";

to="yes";

}

});

}

if(i==14)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String mar=b.getText();

String m=text.getText();

if("yes".equals(begin))

{

vc3.add("v3");

}

if(vc1.contains("v1"))

{

vc2.add("v2");

vc1.clear();

}

if(!Vec.contains(".")!vc.contains("a"))

{

text.setText(m.trim()+mar);

Vec.add(".");

}

}

});

}

if(i==15)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String ma=text.getText();

add=Double.parseDouble(ma);

if(what==null)

{

tool=add;

what="add";

}

else

{

tool=tool+add;

text.setText(String.valueOf((tool)));

}

vc.add("a");

vc1.add("v1");

to="+";

}

});

}

if(i==11)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String ma=text.getText();

jq=Double.parseDouble(ma);

if(what==null)

{

tool=jq;

what="jq";

}

else

{

tool=tool-jq;

text.setText(String.valueOf((tool)));

}

vc.add("a");

vc1.add("v1");

to="-";

}

});

}

if(i==3)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String ma=text.getText();

cq=Double.parseDouble(ma);

if(what==null)

{

tool=cq;

what="cq";

}

else

{

tool=tool/cq;

text.setText(String.valueOf((tool)));

}

vc.add("a");

vc1.add("v1");

to="/";

}

});

}

if(i==7)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String ma=text.getText();

cs=Double.parseDouble(ma);

if(what==null)

{

tool=cs;

what="cs";

}

else

{

tool=tool*cs;

text.setText(String.valueOf((tool)));

}

vc.add("a");

vc1.add("v1");

to="*";

}

});

}

if(i==13)

{

b.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

String ma=text.getText();

dy=Double.parseDouble(ma);

if(what=="add")

{

jg=String.valueOf((tool+dy));

}

if(what=="jq")

{

jg=String.valueOf((tool-dy));

}

if(what=="cs")

{

jg=String.valueOf((tool*dy));

}

if(what=="cq")

{

jg=String.valueOf((tool/dy));

}

if(what==null)

{

if(to=="+")

{

tool=add;

jg=String.valueOf(tool+dy);

}

else if(to=="-")

{

tool=jq;

jg=String.valueOf(dy-tool);

}

else if(to=="*")

{

tool=cs;

jg=String.valueOf(dy*tool);

}

else if(to=="/")

{

tool=cq;

jg=String.valueOf(dy/tool);

}

else

{

jg=String.valueOf(dy);

}

}

text.setText(jg);

Vec.clear();

Vec.add(".");

vc.add("a");

vc1.add("v1");

what=null;

tool=0;

}

});

}

}

}

}

class Centernorth extends JPanel {

public Centernorth() {

final JTextField text=Tool.getinstance().getfield();

}

}

class Centerpanel extends JPanel {

public Centerpanel() {

this.setLayout(new BorderLayout(8,7));

Centernorth cn=new Centernorth();

Centercenter cc=new Centercenter();

Centerwest cw=new Centerwest();

this.add(cn,BorderLayout.NORTH);

this.add(cc,BorderLayout.CENTER);

this.add(cw,BorderLayout.WEST);

}

}

class Centerwest extends JPanel {

public Centerwest() {

}

}

class Northpanel extends JPanel {

private JTextField tf;

public Northpanel() {

tf=Tool.getinstance().getfield();

this.add(tf);

}

}

------------------------------------------------------------

才子_辉祝您愉快!

文章名称:关于计算7参数java代码的信息
网站链接:https://www.cdcxhl.com/article40/dojooeo.html

成都网站建设公司_创新互联,为您提供Google网站改版定制网站软件开发外贸网站建设域名注册

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

绵阳服务器托管