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
Tpy6a [65]
3 years ago
6

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

uld 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:
Nana76 [90]3 years ago
8 0

Answer:

import java.util.Scanner;

class SquareDisplay {

 public static void main(String[] args) {

   Scanner scan = new Scanner(System.in);

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

   int num = scan.nextInt();

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

     String s = "X".repeat(num) + "\n";

     System.out.print(s.repeat(num));

   } else {

     // your error handling

   }

   scan.close();

 }

}

Explanation:

You might be interested in
How to find HCF and LCM of a number in Q Basic program?? ​
DerKrebs [107]
CLS
INPUT "Enter the first number"; a
INPUT "Enter the second number"; b
m = a
n = b
WHILE a <> 0
r = b MOD a
b = a
a = r
WEND
l = (m * n) / b
PRINT "HCF is "; b
PRINT "LCM is "; l
3 0
2 years ago
Design the logic for a program that allows a usher to continuously enter numbers until the usher enters 0. Display the sum of th
uysha [10]

int sum = 0, n;

do {cin>>n; sum+=n;}while (n!=0);

cout<<sum;

5 0
4 years ago
Spelling and grammar checking options can be controlled at the word options dialog box. To display this dialog box, begin by cli
Cerrena [4.2K]
By clicking the file tab
8 0
4 years ago
Where do you expect to participate in distance learning from?
DanielleElmas [232]

Answer:

hahaha very funny

Explanation:

pls rate this answer a 5/5 and heart it

3 0
3 years ago
Read 2 more answers
PLS ANSWER ASAP!!
cricket20 [7]

Answer:

1. = c

2.= a

3. = b

Explanation:

8 0
4 years ago
Other questions:
  • The Campus Housing Service helps students find apartments. Owners of apartments fill in information forms about the rental units
    14·1 answer
  • ________________ is a new method or idea or product or enhancement or other means of adding value to an existing product, such t
    14·1 answer
  • قواعد البيانات الموزعه​
    14·1 answer
  • what are the Technologies in regarding of communication technology? Please help me I'll rate you as brainliest!​
    13·1 answer
  • An operating environment for a computer is ____, free of potential contaminants, and with the temperature and humidity range spe
    9·1 answer
  • A particular problem is currently not able to be practically solved by using an algorithm. Which of the following statements abo
    13·2 answers
  • 2. Suppose a computer using direct mapped cache has 220 words of main memory and a cache of 32 blocks, where each cache block co
    10·1 answer
  • WILL MARK BRAINLIEST!!!!!!!!!!!
    13·2 answers
  • You do not need to remove the lead weights inside tires before recycling them. A) TrueB) False
    15·1 answer
  • 1. The Bank manager is imposing a 10% interest rate on the new salary loan to every account in the BPI Family Bank. (ANSWER SHOU
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!