Need help writing a code for my program?
-
Basically, the task is to complete the code for the following *for* loop. (I copied out from textbook, therefore it did not include public class or public static void main etc) for (int i = i; i <= 6;, i ++) { // your code here } The program want to output these numbers by using the integer i. -4 14 32 50 68 86 I found out the sequence is i * 18 - 22, but I don't how to write the program. This is what I did: public class number { public static void main(Strings[] args) { for (int i=1; i <= 6; i++) { i = (i*18)-22; { System.out.println(i); { { And the program was calculated in the wrong method. The ( i ) doesn't goes up by 1,2,3,4,5 or 6, instead the i was replaced by the equation (i*18-22) every times so it outputted something different. Someone please show me how to write the code for this program, and please check your program before you post it. I copied numerous post from people and it was not able to be compiled, thus I urge people who willing to help to check before posting. Thank you so much!
-
Answer:
Just declare another variable like this. int result; for (int i=1; i <= 6; i++) { result = (i*18)-22; System.out.println(result); }
Louis at Yahoo! Answers Visit the source
Other answers
Didn't you already ask this? And didn't I already tell you about the issue with the braces? I cannot help you further if you refuse to listen to what I say. You will need to either correct the syntactical mistake I pointed out, or ask for clarification if you don't understand. The latter can be done via PM, as I have PMs enabled.
green meklar
Related Q & A:
- I need help with a song I heard.Best solution by Yahoo! Answers
- I need help writing an objective for my resume.Best solution by resume-help.org
- Help Writing a CV?Best solution by Yahoo! Answers
- Help writing a cover letter?Best solution by resume-help.org
- Can anyone help with a code for a ford fiesta radio?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.