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
melomori [17]
4 years ago
15

Write a program that asks the user to enter the size of a triangle (an integer from 1 to 50). Display the triangle by writing li

nes of asterisks. The first line will have one asterisk, the next two, and so on, with each line having one more asterisk than the previous line, up to the number entered by the user. On the next line write one fewer asterisk and continue by decreasing the number of asterisks by 1 for each successive line until only one asterisk in displayed. (Hint: Use nested loops; the outside loop controls the number of lines to write, and the inside loop controls the number of asterisks to display on a line. Complete the program by solving the upper triangle followed by the lower triangle.)
Computers and Technology
1 answer:
dsp734 years ago
4 0

Answer:

import java.util.Scanner;

public class num4 {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       int size;

       do{

           System.out.println("Enter size of triangle");

           size = in.nextInt();

       }while(size<=1 || size>=50);

       for(int i = 1; i <= size; ++i) {

           for(int j = 1; j <= i; ++j) {

               System.out.print("* ");

           }

           System.out.println();

       }

       System.out.println();

       //Second triangle bottom up

       for(int i = size; i >= 1; --i) {

           for(int j = 1; j <= i-1; ++j) {

               System.out.print("* ");

           }

           System.out.println();

       }

   }

}

Explanation:

  • Use Scanner class to receive user value for size
  • Use a do......while loop to ensure user entered a valid range (1-50)
  • Use nested loops to print the first triangle from i = 1
  • Print also the second triangle from i = size downwards
You might be interested in
________ uses shared computing resources instead of having local servers or devices to handle computing applications.
Oksanka [162]

Answer:

cloud computing

Explanation:

3 0
3 years ago
How good are vw beetle heaters in winter?
Vinvika [58]
It depends on the heater but in most case it works pretty well
7 0
3 years ago
Which of the following would not be considered metadata for a spreadsheet file?
Genrish500 [490]

Answer:

B.

Explanation:

Metadata is a type of data that dispense details of other data. In simple terms, metadata can be defined as information of a file such as file name, attributes, etc.

<u>In excel sheet, metadata works the same and helps to provide information about </u><u>file name, author name, file size, attributes such as read-only, archieve, hidden, system, location of the file, date and time of creation, modification, or accessed, type of file, etc</u><u>.</u>

From the given options, the information that is not considered or included in metadata is calculation inside the file. Metadata in excel sheet does not include calculations inside the file. Thus option B is the correct answer

7 0
3 years ago
Excel makes reading formulas simpler by ____ each cell reference in the formula and its corresponding cell in the worksheet.
Bess [88]

The correct answer to this question is color coding.

Excel makes formulas easier to identify because they color code the cell reference with the corresponding cell in the worksheet. For example, if cell A1 in the formula is in blue, then the border around A1 will also be blue.

4 0
4 years ago
Hymter. Wants to workin The Energy career field with electrical energy
m_a_m_a [10]

Answer: what is the question

Explanation:

3 0
3 years ago
Other questions:
  • The dashed lines that display on your slide when you are moving an object are
    10·1 answer
  • Which of these is a poetic device walt whitman often uses to emphasize certain ideas in his poems?a. meterb. alliterationc. rhet
    12·1 answer
  • Alfred, a software programmer at Gamma Inc., develops a program that spreads Trojan viruses to the organization’s network. When
    5·1 answer
  • In the dewey decimal sysytem, the call number 800 notes which section
    10·1 answer
  • Why do i get message notifications but when i click on it it says i have no new messages?
    7·1 answer
  • When you open your word-processing program, it opens in a<br> field<br> menu
    9·2 answers
  • List out any five input and output devideos​
    5·1 answer
  • Opposite word of reassembling​
    15·2 answers
  • PLS HELP WITH MY PYTHON HW ILL GIVE YOU BRAINLIEST
    12·1 answer
  • Declaring a member as ____ in the base class provides access to that member in the derived classes but not to anyone else. a. pu
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!