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
ss7ja [257]
3 years ago
6

3) Write a program named Full_XmasTree using a nested for loop that will generate the exact output. This program MUST use (ONLY)

for loops to display the output below. For example the 1st row prints 1 star 2nd row prints 2, the 3rd row print 3 stars and so forth... This program is controlled by the user to input for the amount of row. "Prompt the user to enter the dimensions of the tree" A good test condition is the value of ten rows. (hint***)This program should account for white spaces print("* "). Remember the purpose of print() and println()

Computers and Technology
1 answer:
N76 [4]3 years ago
8 0

Answer:

Following are the code to this question:

//import package

import java.util.*;  

public class Full_XmasTree   //defining class

{        

// defining main method

public static void main(String as[])  

   {  

       int X,a,b; //defining integer variable

       Scanner obx = new Scanner(System.in); // creating Scanner class object

       System.out.print("Please enter: "); //print message

       X = obx.nextInt(); // input value from user

       for (a = 0; a < X; a++) //defining loop to print pattern  

       {

           for (b = X - a; b > 1; b--)//use loop for print white space  

           {

           System.out.print(" ");//print space

           }

           for (b = 0; b <= a; b++) // use loop to print values  

           {

               System.out.print("* "); //print asterisk values

           }

           System.out.println(); //using print method for new line

       }

   }

}

Output:

please find the attachment.

Explanation:

In the given java code, a class "Full_XmasTree" is declared, in which the main method is declared, inside this method three integer variable "X, a, and b", in this variables "a and b" is used in a loop, and variable X is used for user input.

  • In the next line, the Scanner class object is created, which takes input in variable X, and for loop is used to print asterisk triangle.
  • In the first for loop, use variable a to count from user input value, inside the loop, two for loop is used, in which first is used to print white space and second is used for the print pattern.

You might be interested in
why does it not let me create a new account when i log out of this one and go to join now after i fill everything out it wont le
frozen [14]
Try linking an email to your account, if it doesn’t work select forgot your password and you should receive an email where you can re make or change your password to something easier to remember. Are you using the same email account every time, this may also be the reason, if it is the same email they will not allow you to reuse it and it should tell you the email is already in use. Hope this helped
5 0
3 years ago
What is cpu????????????????????????????
Paul [167]

Answer:

CPU

Explanation:

CENTRAL

PROCESSING

UNIT

8 0
3 years ago
Read 2 more answers
What kind of operating system is MS-DOS?
ELEN [110]

MS-DOS is a command-line operating system.

Therefore, the best answer is Command-line.

8 0
3 years ago
Read 2 more answers
How to work a computer cause i don't know how to
VladimirAG [237]

Answer:

power on, connect to internet, download games

6 0
3 years ago
How do you create an external Stylesheet in BlueGriffon
Sever21 [200]
Go to panel and select stylesheet. Hope this helped:)
5 0
2 years ago
Other questions:
  • Easy question how the internet has impacted y’all life
    13·1 answer
  • Technologies are having a negative impact on businesses.
    8·1 answer
  • What are two variables is figure 1 comparing
    10·1 answer
  • When users talk about font size,
    10·2 answers
  • What is the main feature of chat rooms?
    9·2 answers
  • The parts of a memo are _____.
    9·2 answers
  • Question # 6
    11·2 answers
  • How many bits would be needed to count all of the students in class today? There are 40 students.
    10·1 answer
  • Does any of yall play rob lox?
    5·2 answers
  • ____ uses a computer to design and test new products and modify existing ones. Computer-aided manufacturing Just-in-time design
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!