| | |
How do you increment arrays in for loops?
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
How do you do this? I can assign each random values into arrays, but I cannot increment the value so that I can display each values with another for loops. It needs to be 5 to the right..
thanx for the help...
java Syntax (Toggle Plain Text)
import java.util.Scanner; import java.util.Random; public class LabAssgn_laksmono { public static void main(String args[]) { Scanner input = new Scanner(System.in); Random r = new Random(); int user; do { System.out.print("Enter input between 10 to 100: "); user = input.nextInt(); } while(user > 100 || user < 10); int array[] = new int [user]; int values; for(int i = 0 ; i < array.length ; i++) { values = r.nextInt(100) + 1; array[i] = values; for (int j = 1; j <= 5; j++) { System.out.printf("%d ", values); } System.out.println(); } } }
thanx for the help...
Please explain what you expect to see as output, and what you are seeing as output, as well as what was provided as input.
Also, post any exceptions you may be getting.
Also, post any exceptions you may be getting.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
![]() |
Similar Threads
- A couple Qs (arrays, c++, and reading in text files) (C++)
- C++, help!!!!!!! (C++)
- Array troubles? (C++)
- a problem wilth C program (C)
- Arrays (C++)
Other Threads in the Java Forum
- Previous Thread: Card Game Help
- Next Thread: Wireless information sharing system
Views: 3072 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for Java
android api apple applet application arguments array arrays automation bidirectional binary birt bluetooth calculator chat class classes client code columns component database designadrawingapplicationusingjavajslider draw eclipse editor error errors event exception expand file fractal game givemetehcodez graphics gui guidancer helpwithhomework html ide image inetaddress input integer intellij j2me java javamicroeditionuseofmotionsensor javaprojects jme jmf jni jpanel julia link linux list loop map method methods mobile mobiledevelopmentcreatejar myaggfun netbeans newbie number object oracle plazmic print problem program programming project recursion scanner screen server set signing size smart sms smsspam socket sort sql string subclass support swing test threads time transfer tree webservices windows






