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
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
Write a Java program using a single multi-level nested for-loop to display the following pattern (For...
Write a Java program using a single multi-level nested for-loop to display the following pattern (For each iteration, only one character can be printed) : 1,2,3,4,5,6,7,8,9#1,2,3,4,5,6,7,8,9#1,2,3,4,5,6,7,8,9# 3,6,9,12,15,18,21,24,27#3,6,9,12,15,18,21,24,27#3,6,9,12,15,18,21,24,27# 5,10,15,20,25,30,35,40,45#5,10,15,20,25,30,35,40,45#5,10,15,20,25,30,35,40,45#
Write a code snippet to accept integer values coming from a user into an array named...
Write a code snippet to accept integer values coming from a user into an array named snippet and takes in 25 items using a do while loop
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT
Active Questions
  • 3. A fair coin is flipped 4 times. (a) What is the probability that the third...
    asked 24 minutes ago
  • An engineer wants to know if the mean strengths of three different concrete mix designs differ...
    asked 24 minutes ago
  • The National Football League (NFL) records a variety of performance data for individuals and teams. To...
    asked 34 minutes ago
  • Associated Strategies obtained significant influence over Cece Corporation by buying 30% of Cece’s 50,000 outstanding shares...
    asked 35 minutes ago
  • A survey of 25 randomly selected customers found the ages shown​ (in years). The mean is...
    asked 39 minutes ago
  • (1)         For this discussion, I would like for you to identify and describe two out of...
    asked 40 minutes ago
  • Determine the open intervals on which the graph is concave upward or concave downward. (Enter your...
    asked 41 minutes ago
  • 9- What is the most widely used technique for determining the best combination of debt and...
    asked 41 minutes ago
  • Katsumoto Inc. (Katsumoto) manufactures and sells collectible swords. Katsumoto currently operates at 80% of its 15,000-unit...
    asked 43 minutes ago
  • A researcher wishes to estimate the percentage of adults who support abolishing the penny. What size...
    asked 50 minutes ago
  • Discuss why the longer-term generation of positive free cash flow is important to the providers of...
    asked 55 minutes ago
  • The three main areas for memory in the brain involve the Hippocampus, the Basal Ganglia, and...
    asked 1 hour ago