1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
My name is Ann [436]
3 years ago
11

19. Squares. Write a program class named SquareDisplay that asks the user for a positive integer no greater than 15. The program

should then display a square on the screen using the character ‘X’. The number entered by the user will be the length of each side of the square. For example, if the user enters 5, the program should display the following: XXXXX XXXXX XXXXX XXXXX XXXXX INPUT and PROMPTS. The program prompts for an integer as follows: "Enter an integer in the range of 1-15: ". OUTPUT. The output should be a square of X characters as described above. CLASS NAMES. Your program class should be called SquareDisplay java
Computers and Technology
1 answer:
BaLLatris [955]3 years ago
4 0

Answer:

Explanation:

import java.util.Scanner;

public class SquareDisplay {

   public static void main(String []args){

    // Scanner is used to get value from command line

       Scanner console = new Scanner(System.in);

       System.out.print("Enter an integer in the range of 1-15:");

       int number = console.nextInt();

   // check if number is greater then 15 or less then 1 then return error message

       if(number>0 && number<=15){

           System.out.println("Error :Wrong Input");

           return;

       }

       for( int i=0; i< number; i++){

           for( int j =0; j<number; j++){

               System.out.print("X");

           }

           System.out.print(" ");

       }

   }

}

Code Explanation

As we want to show the square of X's we need to execute 2 nested for loop to achieve the target result. Outer for loop will determine that how many times we need to show the group of X's.

And the inner for loop will actually display's number of X's for every outer loop iteration.

Output

Case 1:

Enter an integer in the range of 1-15:5

XXXXX XXXXX XXXXX XXXXX XXXXX

Case 2:

Enter an integer in the range of 1-15:16

Error :Wrong Input

Case 3:

Enter an integer in the range of 1-15:2

XX XX

You might be interested in
You are the network administrator for a rapidly growing company with a 100BaseT network. Users have recently complained about sl
densk [106]

Answer:

switch

Explanation:

You are the network administrator for a rapidly growing company with a 100BaseT network. Users have recently complained about slow file transfers. In a check of network traffic, you discover a high number of collisions. Which connectivity device …

✓ Switch

6 0
2 years ago
ANY MHA FANS SAY DEKU
Elina [12.6K]

Answer:

DEKU IS BEST

Explanation:

8 0
3 years ago
The number of distinct proper subsets of a set with n elements is.
777dan777 [17]

Answer:

Their are sets of the numbers that you add and subtract

Explanation:

8 0
3 years ago
Help fast pls will mark brainliest - What model is best to use for large complex accounting software that can be broken down int
Nata [24]
The answer is RAD model
6 0
3 years ago
What is syntax?
kkurt [141]

Answer:

A

Explanation:

5 0
3 years ago
Other questions:
  • Write a function namedadd_complex that adds the correspondingnumbers of its arguments (both complexstructures), then returns the
    5·1 answer
  • According to Ohm's Law current equals what?
    7·2 answers
  • When using the Simple Query Wizard, Kirsten wanted to transfer all of her available data to a new table. She should click
    14·1 answer
  • Which of the following are TRUE? A function can call another function. As long as the function is defined anywhere in your progr
    14·1 answer
  • As a project manager, why is analysis an important aspect of the job?
    10·1 answer
  • Does anyone know how I can "guest browsing" when it's blocked ?
    7·1 answer
  • What is the first step in finding a solution to a problem
    13·1 answer
  • Using complete sentences post a detailed response to the following.
    15·1 answer
  • Using AI to filter potential job applicants might be considered _____
    11·2 answers
  • Explain two protocols to enhance cellular networks capacity?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!