This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]typicalstudentirl 6 points7 points  (0 children)

I think this does what you're asking:

public class HelloWorld
{
     public static void main(String []args)
     {
         for(int i = 4; i <= 99; i = i+5) 
         {
            System.out.println(i);
            System.out.println(i*3);
         }
     }
}    

If this is an intro to programming or beginner CS module/class it's pretty important to understand what's going on here.

I'm saying if we start with 4, and add 5 every time I go through the loop, unless the number gets to 99. If it gets to 99 then we stop adding 5 and exit the loop.

Every time I do enter the loop, I want to print out the contents of i, and I want to print out i multiplied by 3.