Question

implement a program that reads a number of rows and a symbol. The program will draw...

  1. implement a program that reads a number of rows and a symbol. The program will draw a square with the specified number of rows and the provided symbol. For example, if the user enters 5 as the number of rows and * as the symbol, the program will print the following diagram:
                    * * * * *
                    * * * * *
                    * * * * *
                    * * * * *
                    * * * * *
  2. For this problem:
    • The square will be drawn by a function called drawRectangle that has the following prototype: function drawSquare(maxRows, symbol)
    • Write JavaScript code outside of the function that will read the number of rows using prompt and the message "Enter number of rows". The function will then read the symbol using prompt and the message "Enter symbol (e.g., *)". After reading this data, the code will call the drawSquare function.
    • Your program must work for different number of rows and symbols.
0 0
Add a comment Improve this question Transcribed image text
Answer #1
function drawSquare(maxRows, symbol) {
    for (var i = 0; i < maxRows; i++) {
        var s = "";
        for (var j = 0; j < maxRows; j++) {
            s += symbol + " ";
        }
        console.log(s);
    }
}

var rows = prompt("Enter number of rows");
var symbol = prompt("Enter symbol (e.g., *)");
drawSquare(rows, symbol);

Add a comment
Know the answer?
Add Answer to:
implement a program that reads a number of rows and a symbol. The program will draw...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write the program FindPatientRecords that prompts the user for an ID number, reads records from Patients.txt,...

    Write the program FindPatientRecords that prompts the user for an ID number, reads records from Patients.txt, and displays data for the specified record. If the record does not exist, display the following error message: No records found for p# using System; using static System.Console; using System.IO; class FindPatientRecords { static void Main() { // Your code here } }

  • Write the program FindPatientRecords that prompts the user for an ID number, reads records from Patients.txt,...

    Write the program FindPatientRecords that prompts the user for an ID number, reads records from Patients.txt, and displays data for the specified record. If the record does not exist, display the following error message: No records found for p# using System; using static System.Console; using System.IO; class FindPatientRecords { static void Main() { // Your code here } }

  • c++ CSI Lab 6 This program is to be written to accomplish same objectives, as did...

    c++ CSI Lab 6 This program is to be written to accomplish same objectives, as did the program Except this time we modularize our program by writing functions, instead of writing the entire code in main. The program must have the following functions (names and purposes given below). Fot o tentoutefill datere nedefremfite You will have to decide as to what arguments must be passed to the functions and whether such passing must be by value or by reference or...

  • implement a program that reads a word and opens one of the following web pages based...

    implement a program that reads a word and opens one of the following web pages based on the word provided: (name it file 1.html) Word                Site Twitter              twitter web site Facebook         Facebook web site yahoo               yahoo web site If the provided word is not part of the above table, your program will open a page called error.html. The error.html page is a page you will define that will display the message "We cannot process your request". Use...

  • Using Visual Studio 2017 Create This Program Using C# implement source code Program 5: The concept...

    Using Visual Studio 2017 Create This Program Using C# implement source code Program 5: The concept of a 5-digit palindrome number is a 5-digit number that reads the same from left to right and from right to left. For example, 12121, 45454, and 14741 are valid 5-digit palindrome numbers. Design (pseudocode) and implement (source code) a program (name it FiveDigitPalindrom) that reads a 5-digit number from the user (as integer value, not string) and then mathematically (using division and remainder...

  • this program is in C. Write a program that computes the number of elements in an...

    this program is in C. Write a program that computes the number of elements in an array divisible by a user specified number. Declare an integer array of size 7 and read the array elements from the user. Then, read a number k from the user and compute the number of elements in the array divisible by k. Consider the following example. 3 elements in this array are divisible by 2 ({2,2,4}). Sample execution of the program for this array...

  • Using visual Studio C# 1. In one text box, your program must except a letter (A-Za-z),...

    Using visual Studio C# 1. In one text box, your program must except a letter (A-Za-z), a number (0-9), or a special symbol (#@!$%^&*). 2. If the user enters a letter, call a module, displayLetter. Pass the letter they entered into the module. The module will then display a figure (stick man?) using the letter the person entered. 3. If the user enters a number, call a module displayNumber. Pass the number they entered into the module. The module will...

  • Is Prime Number In this program, you will be using C++ programming constructs, such as functions....

    Is Prime Number In this program, you will be using C++ programming constructs, such as functions. main.cpp Write a program that asks the user to enter a positive integer, and outputs a message indicating whether the integer is a prime number. If the user enters a negative integer, output an error message. isPrime Create a function called isPrime that contains one integer parameter, and returns a boolean result. If the integer input is a prime number, then this function returns...

  • Problem 1 - Print positive message Create a new project named whatever you want in Visual...

    Problem 1 - Print positive message Create a new project named whatever you want in Visual Studio using the Windows Desktop Wizard or in Xcode. If you're using Visual Studio, add a main.c file to your project; you can use the main.c template I provided on Canvas if you'd like. If you're using Xcode, Xcode automatically generates a main.c file for you. Read in an integer from the user; don't prompt for the user input, because that will confuse the...

  • In C code 1. Write and submit the algorithm OR flowchart to indicate you understand the...

    In C code 1. Write and submit the algorithm OR flowchart to indicate you understand the problem 2. Create a project and name the source code lastname_firstname_prog5.c 3. Use the prog5.c as a guide, copy/ paste into your project source code *** build run and test, the outline code - You will need to declare an integer variable called again and initialize it 4. Add the function prototype and implement the function definition for the Greeting function 5. Add the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT