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 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 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 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";
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...
(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.
(8 marks) Write a program to ask user to input an integer and display the special...
Write a program to ask user to input an integer and display the special pattern accordingly. REQUIREMENTS The user input is always correct (input verification is not required). Your code must use loop statements (for, while or do-while). Your program should use only the following 3 output statements, one of EACH of the followings: System.out.print("-"); // print # System.out.print("+"); // print + System.out.println(); // print a newline Your code must work exactly like the following example (the text in bold...
Write java program to print the following shape N lines. * * * * * *...
Write java program to print the following shape N lines. * * * * * * * * * * * * * * * * * * * * * Input: N Output: The printed shape
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 called Decision that includes a while loop to prompt the user to...
Write a Java program called Decision that includes a while loop to prompt the user to enter 5 marks using the JOptionPane statement and a System. Out statement to output a message inside the loop highlighting a pass mark >= 50 and <= 100. Any other mark will output a messaging stating it’s a fail. Example of the expected output is as follows: