我必须创建一个循环12次的循环 [英] I have to create a loop that loops through 12 times

查看:81
本文介绍了我必须创建一个循环12次的循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不一定有代码。我只需要知道如何创建一个循环大约12次的循环,当在Eclipse中创建一个表时,我怎么能这样做,因为我研究了很多不同的时间如何和我没有找到任何销售的东西。我的老师告诉我使用printf非常有帮助。



我尝试过:



如果有帮助,这就是我所拥有的:



I don't necessarily have a code. I just need to know how I could create a loop that loops around 12 times, and when creating a table in Eclipse, how I could I do that because I researched so many different times how to and I haven't found anything sold. My teacher told me using printf is really helpful.

What I have tried:

This is what I have if it helps:

        int Month = 1;
double startingBalance = 4000.00;
int interestEarned = 0;
double endingBalance = 0.0;

System.out.printf(Month,  startingBalance, interestEarned, endingBalance);

while (Month <= 12) {
    Month = Month + 1;

}
while (startingBalance <= 4000.00) {
    startingBalance = startingBalance * .004;
}

while (interestEarned >= 0) {
    interestEarned =

推荐答案

引用:

我只需要知道如何创建一个循环12次循环

I just need to know how I could create a loop that loops around 12 times



怎么说没有粗鲁?

您列出的代码已包含2个循环,其中1个循环循环12次。


How to say without being rude ?
The code you listed already contain 2 loops and 1 of them loops 12 times.

int Month = 1;
...
while (Month <= 12) {
    Month = Month + 1;
}



您确定此代码是您的吗?



[更新]


Are you sure this code is yours ?

[Update]

Quote:

我不确定我在该代码中做的是否正确

I wasn't sure if what I was doing in that code was correct



有一个工具可以让你看到代码在做什么,它的名字是调试器。掌握调试器不是可选的,它对任何程序员都是强制性的,也不例外。

它也是一个很好的学习工具,因为它向你展示了现实,你可以看到哪个期望与现实相符。

当你不明白你的代码在做什么或为什么它做它的作用时,答案是调试器

使用调试器查看你的代码是什么代码正在做。只需设置断点并查看代码执行情况,调试器允许您逐行执行第1行并在执行时检查变量,这是一个令人难以置信的学习工具。



调试器 - 维基百科,免费的百科全书 [ ^ ]

JavaScript调试 [ ^ ]

Chrome DevTools  | 网络  |  Google Developers [ ^ ]

调试器在这里向您展示您的代码正在做什么,您的任务是与它应该做什么进行比较。

调试器中没有魔法,它不是'找到错误,它只是帮助你。当代码没有达到预期的效果时,你就会接近一个错误。


There is a tool that allow you to see what your code is doing, its name is debugger. Mastering the debugger is not optional, it is mandatory for any programmer, no exception.
It is also a great learning tool because it show you reality and you can see which expectation match reality.
When you don't understand what your code is doing or why it does what it does, the answer is debugger.
Use the debugger to see what your code is doing. Just set a breakpoint and see your code performing, the debugger allow you to execute lines 1 by 1 and to inspect variables as it execute, it is an incredible learning tool.

Debugger - Wikipedia, the free encyclopedia[^]
JavaScript Debugging[^]
Chrome DevTools  |  Web  |  Google Developers[^]
The debugger is here to show you what your code is doing and your task is to compare with what it should do.
There is no magic in the debugger, it don't find bugs, it just help you to. When the code don't do what is expected, you are close to a bug.


这篇关于我必须创建一个循环12次的循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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