Question

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#

Homework Answers

Answer #1
// TestCode.java
public class TestCode {
    public static void main(String args[])
    {
        for(int i = 1;i<=5;i+=2){
            int n = i;
            for(int j = 1;j<27;j++){
                if(j%9==0){
                    System.out.print(n+"#");
                    n = 0;
                }
                else{
                    System.out.print(n+",");
                }
                n += i;
            }
            System.out.println(9*i+"#");
        }
    }
}

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
Step 2 Exercise - Using while loop:    Write a Java program (using while loop) to display...
Step 2 Exercise - Using while loop:    Write a Java program (using while loop) to display 5 lines of smiley faces. The following would be the output of your program: Note: Sample program is in the "Important Documents", Module 6 folder) Hello:                          Bye!
Write a nested FOR loop (using two for loops & two fprintf statements to generate the...
Write a nested FOR loop (using two for loops & two fprintf statements to generate the following pattern: ***** **** *** ** *
Write code in JAVA Write a program that will output a right triangle based on user...
Write code in JAVA Write a program that will output a right triangle based on user specified input height (int) and specified input symbol (char).The first line will have one user-specified character, such as % or *. Each subsequent line will have one additional user-specified character until the number in the triangle's base reaches specified input height. Output a space after each user-specified character, including after the line's last user-specified character. Hint: Use a nested for loop. Ex:If the input...
write a program (in Java/Eclipse to loop through a string character by character. If the character...
write a program (in Java/Eclipse to loop through a string character by character. If the character is a letter, print a question mark, otherwise print the character. Use the code below for the message string. This will be the first string that you will decode. Use the String class method .charAt(index) and the Character class method .isLetter(char). (You can cut and paste this line into your program.) String msg = "FIG PKWC OIE GJJCDVKLC MCVDFJEHIY BIDRHYO.\n";
1) Write a java programming nested while loop where you will declare two numbers one for...
1) Write a java programming nested while loop where you will declare two numbers one for outer loop and the other one for inner while loop, and display the result. (Try using scanner) Steps: 1) Declare the variable of outer loop int and assign value of your choice 2) Declare while condition which outer variable is less the number of your choice 3) Declare variable of inner loop int and assign the value of your choice 4) Declare while condition...
Store Sales in Python Write a program that uses nested for loops to collect sales data...
Store Sales in Python Write a program that uses nested for loops to collect sales data per store and calculate the total and average sales for specified months. The program should first ask for the number of stores and the number of months. After each store iteration it should display the average and total sales for that store. After all iterations, the program should display the total and average sales for all the stores
Write a java program to display a given range of integer numbers (0 to 9) in...
Write a java program to display a given range of integer numbers (0 to 9) in the following order: Example : given (5 to 9), the program displays 56789 67895 78956 89567 95678 The first line displays the min to max range. Each line that follows should display the next higher number except when it hits the maximum number. In that situation, the line wraps back to the minimum sequence. For this problem write a static method to do the...
Write a Java program to display a letter grade based on an actual grade. USING ECLIPSE...
Write a Java program to display a letter grade based on an actual grade. USING ECLIPSE IDE A = 90-100 B = 80-89 C = 70-79 D = 60-69 F = less than 60 The program needs to do the following: 1. Create a short integer to store a grade. (See Week 3 - Things to Know - Java Data Types ) 2. Prompt for a grade ( 0-100). 3. Based on the grade given, use IF statements to display...
use python Write a program that uses a for loop to display all prime numbers within...
use python Write a program that uses a for loop to display all prime numbers within the range [500, 800] (hint: prime numbers are numbers that have only 2 factors: 1 and themselves. You can use a loop function to check if a number has a factor other than 1 or itself using % operation)
(AdditionTable.java) Write a program that displays the following addition table. Notes: You must use a nested...
(AdditionTable.java) Write a program that displays the following addition table. Notes: You must use a nested loop. There are spaces at the beginning of each row.
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT