Question

JAVA: How could you print a rectangle with a specific number of rows and columns, and...

JAVA:

How could you print a rectangle with a specific number of rows and columns, and split it into sections that each print a different inputted symbol?

For example, if rows = 16, columns = 10, and the sections = 4 where the three symbols = #, $, and % the following would print:

##########

##########

##########

##########

$$$$$$$$$$

$$$$$$$$$$

$$$$$$$$$$

$$$$$$$$$$

**********

**********

**********

**********

##########

##########

##########

##########

Where the pattern repeats until the number of sections is met.

Homework Answers

Answer #1
//TestCode.java
public class TestCode {
    public static void main(String[] args) {
        char arr[] = {'#','$','%'};
        int rows = 16, columns = 10, sections = 4;

        for(int i = 0;i<rows;i++){
            for(int j = 0;j<columns;j++){
                if(i/sections==0 || i/sections==3){
                    System.out.print(arr[0]);
                }
                else if(i/sections==1){
                    System.out.print(arr[1]);
                }
                else{
                    System.out.print(arr[2]);
                }
            }
            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
JAVA How could you print a rectangle with a specific number of rows and columns, and...
JAVA How could you print a rectangle with a specific number of rows and columns, and split it into sections that each print a different inputted symbol (without using an array)? For example, if rows = 16, columns = 10, and the sections = 4 where the three symbols = #, $, and % the following would print: ########## ########## ########## ########## $$$$$$$$$$ $$$$$$$$$$ $$$$$$$$$$ $$$$$$$$$$ ********** ********** ********** ********** ########## ########## ########## ########## Where the pattern repeats until the...
JAVA How would you use for loops to print a triangle inside of a rectangle given...
JAVA How would you use for loops to print a triangle inside of a rectangle given the user inputs a specific number of rows and columns for the rectangle? And edit the first and last lines. Not using an array Ex: Rows = 10, Columns = 15 *############## **$$$$$$$$$$$$$ ***$$$$$$$$$$$$ ****$$$$$$$$$$$ *****$$$$$$$$$$ ******$$$$$$$$$ *******$$$$$$$$ ********$$$$$$$ *********$$$$$$ **********$$$$$ **********$$$$$ *********$$$$$$ ********$$$$$$$ *******$$$$$$$$ ******$$$$$$$$$ *****$$$$$$$$$$ ****$$$$$$$$$$$ ***$$$$$$$$$$$$ **$$$$$$$$$$$$$ *##############
JAVA PROGRAMMING: Write a program called TimeSymbolTables that creates three symbol tables, each of a different...
JAVA PROGRAMMING: Write a program called TimeSymbolTables that creates three symbol tables, each of a different implementation. Each symbol table will contain as a key a word read from a text file and as a value the number of times that word occurs in the text file. Have the program fill the first symbol table with these counts, keeping track of how long that takes using a Stopwatch object. It then does the same thing with the second symbol table....
This is in java and you are not allowed to use Java API classes for queues,...
This is in java and you are not allowed to use Java API classes for queues, stacks, arrays, arraylists and linkedlists. You have to write your own implementations for them. You should construct a BST by inserting node values starting with a null tree. You can re-use the code for the insert method given in the sample code from the textbook. -insert method is provided below Your code should have a menu driven user interface at the command line with...
The ability to read through Java™ code and predict the results, given specific inputs, is an...
The ability to read through Java™ code and predict the results, given specific inputs, is an extremely useful skill. For this assignment, you will be analyzing the Java™ code in the linked zip file, and predicting the results given specific input. Carefully read through the code line by line, then answer the following questions in a Microsoft® Word document: What is the output of the program as it is written? What would the output of the program be if you...
Use python language please #One of the early common methods for encrypting text was the #Playfair...
Use python language please #One of the early common methods for encrypting text was the #Playfair cipher. You can read more about the Playfair cipher #here: https://en.wikipedia.org/wiki/Playfair_cipher # #The Playfair cipher starts with a 5x5 matrix of letters, #such as this one: # # D A V I O # Y N E R B # C F G H K # L M P Q S # T U W X Z # #To fit the 26-letter alphabet into...
IN JAVA!! You may be working with a programming language that has arrays, but not nodes....
IN JAVA!! You may be working with a programming language that has arrays, but not nodes. In this case you will need to save your BST in a two dimensional array. In this lab you will write a program to create a BST modelled as a two-dimensional array. The output from your program will be a two-dimensional array.   THEN: practice creating another array-based BST using integers of your choice. Once you have figured out your algorithm you will be able...
***Programming language is Java. After looking at this scenario please look over the requirements at the...
***Programming language is Java. After looking at this scenario please look over the requirements at the bottom (in bold) THIS IS ALL THAT WAS PROVIDED. PLEASE SPECIFY ANY QUESTIONS IF THIS IS NOT CLEAR (don't just say more info, be specific)*** GMU in partnership with a local sports camp is offering a swimming camp for ages 10-18. GMU plans to make it a regular event, possibly once a quarter. You have been tasked to create an object-oriented solution to register,...
You are required to write a Business Plan Report and you are advised to follow the...
You are required to write a Business Plan Report and you are advised to follow the below given outline.  Part I- Product/service idea Business Plan Report (40%) To make the best impression, a business plan should follow a convention structure, such as the outline shown below. Cover page Table of contents 1. Executive Summary  A succinct highlight of the overall plan- include ownership structure, business address, product/service, the management team and strategy and strengths. 2. Industry Analysis ...
Design a FSM for a Vending Machine In this task, you will design a FSM for...
Design a FSM for a Vending Machine In this task, you will design a FSM for a simple (albeit strange) vending machine of office supplies. The vending machine sells three possible items, each at a different cost: Item Cost Pencil 10 cents Eraser 20 cents Pen 30 cents The vending machines accepts nickels (worth 5 cents), dimes (worth 10 cents), and quarters (worth 25 cents). Physically, it is only possible to insert a single coin at a time. The vending...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT