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
daser333 [38]
3 years ago
7

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
Computers and Technology
1 answer:
Mrrafil [7]3 years ago
3 0

Answer:

// program in java.

// package

import java.util.*;

// class definition

class SquareDisplay

{

// main method of the class

public static void main (String[] args) throws java.lang.Exception

{

   try{

    // variable

       int num;

       // scanner object to read input

Scanner scr=new Scanner(System.in);

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

 // read integer from user

num=scr.nextInt();

 // read until input is not in range 1-15

while(num<0 || num>15)

{

    System.out.print("wrong input!!enter again:");

     // read again

    num=scr.nextInt();

}

// print square of X

for(int a=1;a<=num;a++)

{

    for(int b=1;b<=num;b++)

    {

        System.out.print("X");

    }

    System.out.println();

}  

   }catch(Exception ex){

       return;}

}

}

Explanation:

Read an integer from user and assign it to variable "num".Check if input is not  in range 1-15 then ask again until user enter a number between 1-15 only.Then  print a square of character "X" with the help of two nested for loops.

Output:

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

wrong input!!enter again:20                                                                                                

wrong input!!enter again:4                                                                                                

XXXX                                                                                                                      

XXXX                                                                                                                      

XXXX                                                                                                                      

XXXX

You might be interested in
In black and white,<br><br> we must be more conscious of image
scZoUnD [109]

is it true or false is so it is false

3 0
3 years ago
Learning in a digital environment is also called [blank] learning.
Dafna1 [17]

Answer:

The blank is online learning

4 0
3 years ago
Read 2 more answers
1.What is the output of the following program? [10 Marks]namespace ConsoleApp1{class Program{static void Main(string[] args){int
Nataliya [291]

The program outputs the following rectangular array:

0 0 0 0

0 1  2 3

0 2 4 6

0 3 6 9

0 4 8 12

This is the correctly formatted C# program:

namespace ConsoleApp1{

   class Program

   {

       static void Main(string[] args)

       {

           int i, j;    // <em>declare index variables used to iterate over the array A</em>

           int [,] A = new int[5,5];   // <em>create a 5 by 5 array</em>

           

           /*<em> Iterate over the array with the index variables i and j</em>

<em>                and initialize each location A[i, j] with the product </em>

<em>                of i and j.</em> */  

           for (i = 0; i < 5; ++i)

           {

               for (j = 0; j < 4; ++j)

               {

                   A[i, j] = i*j;

               }

           }

           

           /* <em>Iterate over the array again. This time, swap locations </em>

<em>                A[i, j] with A[j, i]</em> */

           for (i = 0; i < 5; ++i)

           {

               for (j = 0; j < 4; ++j)

               {

                   if (i < 5)

                   {

                       A[j, i] = A[i, j];

                   }

                   else

                       break;

                   

                   // <em>display the current location A[i, j]</em>

                   Console.Write(A[i, j] + " ");

                   

               }

               /* <em>print a newline to prepare for the next line of printing</em>

                   <em>which corresponds to the next column i</em> */

               Console.WriteLine();

                // <em>pause and wait for user keypress before continuing</em>

               Console.ReadLine();

               

               }

           }

       }

   }

When executed, this program simply prints a rectangular array like so;

0 0 0 0

0 1  2 3

0 2 4 6

0 3 6 9

0 4 8 12

Learn more about predicting program output here: brainly.com/question/20259194

6 0
3 years ago
Jake is photographing his pet puppy. He wants to preview the image the camera will capture. What part of the camera that is insi
german

A. i think that is right

3 0
3 years ago
Read 2 more answers
Some scientists say that robots my become self - aware in the near future Do you think this is possible?​
galben [10]

Answer:

i believe that robots could become self aware because its called artificial intelligence, and that means that they can pretty much think for themselves

Explanation:

its just my opinion but i hope i helped!

6 0
3 years ago
Other questions:
  • What is an extrinsic value? A. something that is valuable in and of itself B. something that is valuable because it leads to ano
    12·1 answer
  • Check My Work _____ are made in response to situations that have occurred frequently enough to enable managers to develop decisi
    15·1 answer
  • All of the following items could be too expensive for someone with only a high school degree to afford except
    6·1 answer
  • Incident damage ____ is the rapid determination of the scope of the breach of the confidentiality, integrity, and availability o
    6·1 answer
  • Which of the following takes place during the research phase
    7·1 answer
  • What information is displayed in the title bar?
    10·1 answer
  • A company that manufactures machine parts orders a new system that makes products at ten times the speed of the earlier machine.
    15·1 answer
  • In the design phase of the systems development life cycle (SDLC), the _____ design is an overview of the system and does not inc
    10·1 answer
  • I need help. I wanna help a friend by giving him my powerpoint but I dont want him to steal my work. Is their anyway to restrict
    8·1 answer
  • A _________________ operating system accepts random enquires from remote locations and provides an instantaneous response
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!