Question

Write a Java code snippet with a nested for loop to print five rows of six...

Write a Java code snippet with a nested for loop to print five rows of six random integers between 5 and 10 inclusive.

Homework Answers

Answer #1
// TestCode.java
import java.util.Random;
public class TestCode {
    public static void main(String[] args) {
        Random rand = new Random();
        for(int i = 0;i<5;i++){
            for(int j = 0;j<6;j++){
                System.out.print((rand.nextInt(6)+5)+" ");
            }
            System.out.println();
        }
    }
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Create a Java application using nested for loops to print five rows of seven randomly generated...
Create a Java application using nested for loops to print five rows of seven randomly generated integers between 1 and 9 inclusive.
In Java programming language 11.Create the code for a for loop to print the numbers 1  through...
In Java programming language 11.Create the code for a for loop to print the numbers 1  through 5 inclusive vertically so the output is 1 2 3 4 5 11b What is the output of the following               OUTPUT int i=3; while(int i >0) { System.out.println(i); i--; } 11c What is the output of the following               OUTPUT for(int i=3;i<10;i++) System.out.println(3*i); 11d Create the line of code to print the numbers 10 through 1 decreasing by 1 each time 11e Create the line of code...
I am having some trouble writing some java code involving strings. I have included the code...
I am having some trouble writing some java code involving strings. I have included the code provided by my professor below. that has the instructions in it as well public class StringExercise { public static void main(String[] args) { String given = "The quick brown fox jumped over the moon!"; String given2 = "mary"; String given3 = "D"; //Write a Java code snippet to check (print a boolean) whether the given String ends with the contents of "oon!", see endsWith...
Print a list of seats in a theater. Rows are numbered, columns lettered, as in 1A...
Print a list of seats in a theater. Rows are numbered, columns lettered, as in 1A or 3E. Print a space after each seat. Create a nested loop to print the following (IN JAVA): 1A 1B 1C 1D 3A 3B 3C 3D 5A 5B 5C 5D
Python Code Use (for loops) inside another for loop (a nested loop) to do the following:...
Python Code Use (for loops) inside another for loop (a nested loop) to do the following: Print Hello 30 times followed by Bye 10 times. Do that whole thing 15 times. (for a total of 600 lines of output) #Hint: First write the code that prints 30 "Hello" and then 10 "Bye". Think of that as two separate tasks, each of which requires its own for loop. THEN, once you get that working, put all of that inside ANOTHER loop...
C# code required Write two code segments that print the integers 1 through 10. One segment...
C# code required Write two code segments that print the integers 1 through 10. One segment should use a while loop and the other should use a for loop.
C++ Code! Represent the following matrix using a two-dimensional array and write a nested for loop...
C++ Code! Represent the following matrix using a two-dimensional array and write a nested for loop to initialize the elements (do not initialize the array in the declaration): 10  9   8 7   6   5 4 3   2
Implement a nested for loop to jind the prime number up to n numbers. print all...
Implement a nested for loop to jind the prime number up to n numbers. print all the prime numbers up to N, we start one loop from 2 to N and then inside the loop we check current number or “num” is prime or not. To check if it is prime or not we again need one nested loop. It is not an efficient way to check prime number but it is simpler to understand the basic of looping in...
Using loop logic in a python code snippet, create a loop that counts down from 15...
Using loop logic in a python code snippet, create a loop that counts down from 15 to 5 by 3's printing the count as it is processing. example output: Counter Example count =  15 count =  10 count =  5
write a Nested loop in C# to print out the following output using windows form. 0...
write a Nested loop in C# to print out the following output using windows form. 0 0 1 0 2 4 0 3 6 9 0 4 8 16 32