我如何在java中编写代码 [英] How do I code this in java

查看:90
本文介绍了我如何在java中编写代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编写一系列Java语句,在不使用第三个变量的情况下交换两个数值变量的值。将类保存为InterchangeNumbers.java。



这是一个帮助描述......如果你有两个变量值3和7。



第一个变量等于总和(10)



第二个变量等于总和减去第二个变量的当前值(10-7 = 3)



现在我们将第一个变量放入第二个变量。



第一个变量等于第一个变量减去第二个变量( 10-3 = 7)



就是这样!在不使用第三个变量的情况下切换了变量的值。现在用Java实现:-)



我尝试过:



i试图对它进行编码,但我不理解它。

Write a series of Java statements that interchange the values of two numeric variables without using a third variable. Save the class as InterchangeNumbers.java.

Here is a description to help... If you have two variables which have values 3 and 7.

first variable equals the sum (10)

second variable equals the sum less the current value of the second (10-7=3)

Now we have the first variable into the second variable.

first variable equals the first variable less the second variable (10-3=7)

That's it! Have switched the value of the variables without using a third variable. Now implement this in Java :-)

What I have tried:

i tried to code it but i am not understanding it.

推荐答案

表达,语句和块(Java™教程>学习Java语言>语言基础) [ ^ ]。


我们不做你的作业:它是有原因的。它就是为了让你思考你被告知的事情,并试着理解它。它也在那里,以便您的导师可以识别您身体虚弱的区域,并将更多的注意力集中在补救措施上。



亲自尝试,你可能会发现它不是和你想的一样困难!

仔细阅读说明书并手工试用 - 如果你只是用一张纸写的两个数字,你就会明白这个想法。一旦你看到他正在发生的事情,你需要编码就很明显了。



如果遇到特定问题,那么请问一下我们会尽力帮助。但我们不打算为你做这一切!
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!
Read the instructions carefully and try them by hand - you'll get the idea if you just use two numbers written on a piece of paper. Once you see what he is going on about, it'll be pretty obvious what you need to code.

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!


这篇关于我如何在java中编写代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆