Jump to content

Need a for loop Quick!

PugoOfficial

I Use Java (JCreator) I need a for loop guys even a simple one or one that is inputed by a user thnx in adv.

CPU: Intel Core i7-4790K @ 4.0GHz | COOLING: Corsair H100i Liquid Cooler | MOTHERBOARD: ASUS Maximus VII Formula ATX | MEMORY: Corsair Vengeance Pro Series 16GB (2 x 8) DDR3-1866 | STORAGE: Intel 730 Series 480GB SSD + Seagate Barracuda 3TB HDD | PSU: Corsair AX860i 80+ Platinum | GPU: ASUS GeForce GTX 780Ti DirectCU II (2-Way SLI) | CASE: Phanteks Enthoo Luxe (Black) | DISPLAY: ASUS PB278Q 27.0" (2560 x 1440) | KEYBOARD: Razer BlackWidow Chroma | MOUSE: Razer Deathadder Chroma | SOUND: Logitech Z906 5.1 Speakers / Razer Kraken Chroma | OS: Microsoft Windows 8.1 (64-bit)

Link to comment
Share on other sites

Link to post
Share on other sites

I don't know java, but as kind as I am I had to google it and that's what I've found: http://docs.oracle.com/javase/tutorial/java/nutsandbolts/for.html

I hope this is what you need.

-edit: Now I think about it, don't you learn this with the very basics of java? At least for me loops where one of the first things I learnt in C++

I once had one of these, now I've got this.

Link to comment
Share on other sites

Link to post
Share on other sites

I don't know java, but as kind as I am I had to google it and that's what I've found: http://docs.oracle.com/javase/tutorial/java/nutsandbolts/for.html

I hope this is what you need.

-edit: Now I think about it, don't you learn this with the very basics of java? At least for me loops where one of the first things I learnt in C++

do you have a for loop that is inputed by the user not the programmer?

CPU: Intel Core i7-4790K @ 4.0GHz | COOLING: Corsair H100i Liquid Cooler | MOTHERBOARD: ASUS Maximus VII Formula ATX | MEMORY: Corsair Vengeance Pro Series 16GB (2 x 8) DDR3-1866 | STORAGE: Intel 730 Series 480GB SSD + Seagate Barracuda 3TB HDD | PSU: Corsair AX860i 80+ Platinum | GPU: ASUS GeForce GTX 780Ti DirectCU II (2-Way SLI) | CASE: Phanteks Enthoo Luxe (Black) | DISPLAY: ASUS PB278Q 27.0" (2560 x 1440) | KEYBOARD: Razer BlackWidow Chroma | MOUSE: Razer Deathadder Chroma | SOUND: Logitech Z906 5.1 Speakers / Razer Kraken Chroma | OS: Microsoft Windows 8.1 (64-bit)

Link to comment
Share on other sites

Link to post
Share on other sites

do you have a for loop that is inputed by the user not the programmer?

Do you mean how often it should be repeated? If yes just make ask the user for the a number, put it into a variable and then use the variable as the termination.

I once had one of these, now I've got this.

Link to comment
Share on other sites

Link to post
Share on other sites

The Programmer will ask the user to input a starting number then ask for a ending number the system will now count from the starting number to ending number and that's it :)

CPU: Intel Core i7-4790K @ 4.0GHz | COOLING: Corsair H100i Liquid Cooler | MOTHERBOARD: ASUS Maximus VII Formula ATX | MEMORY: Corsair Vengeance Pro Series 16GB (2 x 8) DDR3-1866 | STORAGE: Intel 730 Series 480GB SSD + Seagate Barracuda 3TB HDD | PSU: Corsair AX860i 80+ Platinum | GPU: ASUS GeForce GTX 780Ti DirectCU II (2-Way SLI) | CASE: Phanteks Enthoo Luxe (Black) | DISPLAY: ASUS PB278Q 27.0" (2560 x 1440) | KEYBOARD: Razer BlackWidow Chroma | MOUSE: Razer Deathadder Chroma | SOUND: Logitech Z906 5.1 Speakers / Razer Kraken Chroma | OS: Microsoft Windows 8.1 (64-bit)

Link to comment
Share on other sites

Link to post
Share on other sites

Do you mean how often it should be repeated? If yes just make ask the user for the a number, put it into a variable and then use the variable as the termination.

Can you write it in code? I simply can't understand how to do it, Im still a newb at programming

CPU: Intel Core i7-4790K @ 4.0GHz | COOLING: Corsair H100i Liquid Cooler | MOTHERBOARD: ASUS Maximus VII Formula ATX | MEMORY: Corsair Vengeance Pro Series 16GB (2 x 8) DDR3-1866 | STORAGE: Intel 730 Series 480GB SSD + Seagate Barracuda 3TB HDD | PSU: Corsair AX860i 80+ Platinum | GPU: ASUS GeForce GTX 780Ti DirectCU II (2-Way SLI) | CASE: Phanteks Enthoo Luxe (Black) | DISPLAY: ASUS PB278Q 27.0" (2560 x 1440) | KEYBOARD: Razer BlackWidow Chroma | MOUSE: Razer Deathadder Chroma | SOUND: Logitech Z906 5.1 Speakers / Razer Kraken Chroma | OS: Microsoft Windows 8.1 (64-bit)

Link to comment
Share on other sites

Link to post
Share on other sites

Can you write it in code? I simply can't understand how to do it, Im still a newb at programming

Someone else might have to write it, cause I don't know java (yet).

I once had one of these, now I've got this.

Link to comment
Share on other sites

Link to post
Share on other sites

I don't know java (i'll start to study it soon though), anyway should be similar to this:

            Console.WriteLine("n1?");            int n1 = int.Parse(Console.ReadLine());            Console.WriteLine("n2?");            int n2 = int.Parse(Console.ReadLine());            for (int x = n1; x <= n2; x++)            {                Console.WriteLine(x.ToString());            }

I wrote it in C# didn't try it but should work, and should be easy to translate in Java

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×