Sub-Heading Here

hello guys, am new here and am looking forwad to getting a lot of help and helping others as well. I have an assignment that requires a program that outputs the numbers 1,2,4,8,16,32,64,128 using a loop.

DaniWeb Member Rules include:
"Do provide evidence of having done some work yourself if posting questions from school or work assignments"
http://www.daniweb.com/community/rules

Post what you have done so far and someone will help you from there.

Even though it is an easy task, we still need to have a look at your work you've done. I will get you started on that one. Next time, do post your code that you have trouble with.

for( int i=0; i<150; i++){
    System.out.println("the output is  " + i);
}

Try playing around with this snippet until you get your head around it. To explain it, the variable i starts at 0 and increases by one every time it enters the loop.

I hope that helps.

Well, to start you with, what is a loop? It's a task that is repeatedly done till one or more conditions are fullfilled. Examples of loops would be:

while (condition){
    //do stuff
}

or

do{
    //do stuff
} while (condition)

or

for (beginning of condition ; end of condition ; steps of the condition) {
    //do stuff
}

Either ways, check that info out of google, I'm prety sure you'll find some decent tutorials, and than try to create your own code using the knowledge from those tutorials.
We are here to answer/help you in your problems with your code/thinking of solving a problem etc., but this assignment is pretty easy, and the information to solving this problem can be found in your coursebook too.

here's your code:

import java.util.Scanner;

public class times2 {
    public static void main (String [] args) {
        Scanner in = new Scanner (System.in);

        int max = 128; 
        for (int i = 1; i <= max; i*=2){
            System.out.print (i + " ");
        }

    }
}

@latecomer:
I guess you posted this before you saw my note on your previous post? Please do not use these forums to provide a "we help you cheat your homework" service. Help the OP develop their own Java skills.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.