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
DaniilM [7]
3 years ago
15

1. Write an application that prompts the user to enter the size of the side of a square, and then displays a hollow square of th

at size made of asterisks. Your program should work for squares of all side lengths between 1 and 20. This is a sample run of your program: Enter·the·size·of·the·asterisk·square·from·1-20:3↵ ***↵ *·*↵ ***↵
Computers and Technology
1 answer:
belka [17]3 years ago
4 0

Answer:

import java.util.Scanner;

public class HollowSquare

{

public static void main(String args[])

{

Scanner scan = new Scanner(System.in);

int size;

System.out.print("Enter the size : ");

size = scan.nextInt();

if(size>=1 && size<=20)

{

for(int i=0; i<size; i++)

{

for(int j=0; j<size; j++)

{

if(i==0 || j==0 || i==size-1 || j==size-1)

System.out.print("*");

else

System.out.print(" ");

}

System.out.println();

}

}

else

System.out.println("Invalid size.");

}

}

You might be interested in
Write a calculator program using a switch statement that: a) Prompts the user to enter two numbers b) Prompts the user to select
dlinn [17]

Answer:

// calculator program in C++.

#include <bits/stdc++.h>

using namespace std;

// main function

int main()

{

// variables

int x,y;

int ch;

   cout<<"Enter 1st number:";

   // read first number

   cin>>x;

   cout<<"Enter 2nd number:";

   // read second number

   cin>>y;

   cout<<"Choose 1) for add, 2) for subtract, 3) for multiply or 4) for divide):";

   // read choice

   cin>>ch;

   switch(ch)

   {

       // if choice is 1, find Addition

       case 1:

       cout<<"Addition of two numbers is:"<<(x+y)<<endl;

       break;

       // if choice is 2, find subtraction

       case 2:

       cout<<"Subtract the second from the first is:"<<(x-y)<<endl;

       break;

       // if choice is 3, find multiplication

       case 3:

       cout<<"Multiplication of two numbers is:"<<(x*y)<<endl;

       break;

       // if choice is 4, find division

       case 4:

       cout<<"Division the first by the second is:"<<(x/y)<<endl;

       break;

       // if choice is other

       default:

       cout<<"Wrong choice:"<<endl;

       break;

   }

return 0;

}

Explanation:

Read two numbers from user.Then read the choice of operation from user.If choice is 1, then print the Addition of both numbers.If choice is 2, then print the subtraction. If the choice is 3, then print the multiplication.If choice is 4, then print the  division.If choice is other than these, then print wrong choice.

Output:

Enter 1st number:10                                                                                                      

Enter 2nd number:2                                                                                                      

Choose 1) for add, 2) for subtract, 3) for multiply or 4) for divide):3                                                    

Multiplication of two numbers is:20

5 0
3 years ago
Fill in the blank with the correct response.
SCORPION-xisa [38]
Higher Resolution i guess it depends on what it’s requiring
3 0
3 years ago
Write an expression that computes the average of the values 12 and 40.
Lady bird [3.3K]

Answer:

The answer to this question is given below in the explanation section

Explanation:

The expression that computes the average of value 12 and 40 is given below:

average = (12+40)/2;

in programming language we can write this expression as like;

int average = (12+40)/2;

8 0
4 years ago
Which functions are examples of logical test arguments used in formulas? Check all that apply. OR IF SUM COUNT NOT AND
slavikrds [6]

Answer:Sum functions() and Count functions() of logical test arguments used in formula .

Explanation:The Count () function returns the number of that rows match that a specified column.

Count (column_ Name)

table name

The count SQL Function finds the number condition.

SELECT COUNT(Condition Id)

FROM Condition;

The Sum () Function returns to the total sum number of columns.

SUM (Column_Name)

table name

The Sum SQL Function find the sum of the table.

3 0
3 years ago
Read 2 more answers
In gaming, "rendering" refers to:
jarptica [38.1K]
 The answer to your question is, rendering is<span> the process of generating an image from a 2D or 3D model.</span>
5 0
3 years ago
Read 2 more answers
Other questions:
  • What can a person do to help increase their credit score? AUse only a small percentage of your credit limit. BResearch student l
    8·1 answer
  • If two hosts are connected by five networks, how many frames will there be when one host sends a packet to the other host? 1 2 5
    13·1 answer
  • Don is visiting digital stores and searching the internet to learn about high-definition DVD players before he buys one. This is
    8·1 answer
  • The function below takes two arguments, a dictionary called dog_dictionary and a list of dog names (strings) adopted_dog_names.
    8·1 answer
  • Explain any 10uses of computer that are specific to your field of study giving appropriate examples​
    13·1 answer
  • What type of network would be suitable for linking all computers in a building
    6·1 answer
  • Edhesive 3.5 code practice quetion one
    9·1 answer
  • Which of the following is a valid c++ identifier a. mouse b. _int c. 2_stop d. float​
    10·1 answer
  • A well-known production is making a documentary film titled “The Dwindling Population of Grizzly Bears in the United States.” Wh
    5·1 answer
  • There are some games that cannot be described by a single--or even two-- genres. Can you think of any that should be invented?​
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!