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
Consider the following class definitions.
Serggg [28]

Answer:

The correct answer is option A

Explanation:

Solution

Recall that:

From the question stated,the following segments of code that should be used in replacing the /* missing code */ so that the value 20 will be printed is given below:

Android a = new Android(x);

a.setServoCount(y);

System.out.println(a.getServoCount());

The right option to be used here is A.

4 0
3 years ago
Which tools are found in the Quick Analysis feature? Check all that apply.
a_sh-v [17]

Answer:

A, C, E

Explanation:

8 0
3 years ago
Read 2 more answers
Im on Edge 2021 and i did an assignment that says, "Processing." The assignment won't give me a grade and says it is overdue. wh
lora16 [44]

Answer:

you could send a email to your teacher to fix the problem

Explanation:

3 0
3 years ago
Write a program that computes the minimum, maximum, average and standard deviation of the population over time for a borough (en
IrinaK [193]

Answer:

import pandas as pd #importing pandas library as pd

import matplotlib.pyplot as plt #importing matplotlib.pyplot as plt

pop=pd.read_csv('nycHistPop.csv') #reading the csv file

borough=input('Enter borough name:') #asking the user for borough namme

# image=input('Enter image name:')

# pop['Fraction']=pop[borough]/pop['Total']

# pop.plot(x='Year', y='Fraction')

print("Minimum population",pop[borough].min()) #printing the minimum population of borough

print("Maximum population",pop[borough].max()) #printing the maximum population of borough

print("Average population",pop[borough].mean()) #printing the average population of borough

print("Standard deviation",pop[borough].std()) #printing the standard deviation of borough

# fig=plt.gcf()

# fig.savefig(image)

Explanation:

4 0
3 years ago
A function defined beginning with void SetNegativesToZeros(int userValues[], ... should modify userValues such that any negative
Stels [109]

Answer:

   public static void setNegativesToZero(int userValues[]){

       System.out.println("Array before setting negatives to zero "+Arrays.toString(userValues));

       for(int i=0; i<userValues.length; i++){

           if(userValues[i]< 1){

               userValues[i] = 0;

           }

       }

       System.out.println();

       System.out.println("Array After setting negatives to zero "+Arrays.toString(userValues));

   }

Explanation:

Using Java programming Language, the method is created to receive an array of ints as parameter (as specified in the question)

Using a for loop, we iterate over the entire array checking for values that are negative (<0) and setting them to zero.

See a complete program below

import java.util.Arrays;

import java.util.Scanner;

public class num1 {

   public static void main(String[] args) {

   // Create an array and assign values

       int [] arr = {1,2,3,-1,1,2,-4};

   //Calling the method setNegativesToZero

   setNegativesToZero(arr);

   }

//Creating the Method

   public static void setNegativesToZero(int userValues[]){

       System.out.println("Array before setting negatives to zero "+Arrays.toString(userValues));

       for(int i=0; i<userValues.length; i++){

           if(userValues[i]< 1){

               userValues[i] = 0;

           }

       }

       System.out.println();

       System.out.println("Array After setting negatives to zero "+Arrays.toString(userValues));

   }

}

3 0
3 years ago
Other questions:
  • The spreadsheet below shows the names years in office, and number of terms for five US presidents
    7·2 answers
  • Select the correct answer from each drop-down menu. Select the correct type of address reference.
    6·2 answers
  • The second row of letters on the keyboard is called the______ row
    14·2 answers
  • You use different office apps to accomplish specific tasks, such a creating a newsletter or producing a sales presentation, yet
    8·1 answer
  • After clicking the Start button on your computer screen desktop, what option would you then select to examine system components
    5·1 answer
  • Which of the following is a disadvantage of using face-to-face communication over other communication channels? A) There is lag
    13·1 answer
  • Which of the following is false about arrays? Group of answer choices
    15·1 answer
  • Write the Flowchart to find Even number between 1 to 50<br>​
    9·1 answer
  • PLZ HELP What will be the output? class num: def init (self.a): self. number = a mul* __(self. b) return self. number + b. numbe
    7·1 answer
  • _____ allows information to be viewed at a glance without needing to address the individual elements of the information separate
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!