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
The function below takes one parameter: a string (date_string) containing a date in the mm/dd/year format. Complete the function
Natalija [7]

Answer:

The solution code is written in Python 3.

  1. def convertDate(date_string):
  2.    date_list = date_string.split("/")
  3.    for i in range(0, len(date_list)):
  4.        date_list[i] = int(date_list[i])
  5.    return date_list  
  6. print(convertDate('06/11/1930'))

Explanation:

Firstly, create a function convertDate() with one parameter, <em>date_string</em>. (Line 1).

Next, use the Python string <em>split()</em> method to split the date string into a list of date components (month, day & year) and assign it to variable <em>date_list</em>. (Line 3) In this case, we use "/" as the separator.

However, all the separated date components in the <em>date_list</em> are still a string. We can use for-loop to traverse through each of the element within the list and convert each of them to integer using Python<em> int() </em>function. (Line 5 - 6)

At last return the final date_list as the output (Line 8)

We can test our function as in Line 11. We shall see the output is as follow:

[6, 11, 1930]

8 0
2 years ago
4.2.5 codehs text messages answer
N76 [4]

Answer:

public class TextMessage

{

   private String message;

   private String sender;

   private String receiver;

   

   public TextMessage(String from, String to, String theMessage)

   {

       sender = from;

       receiver = to;

       message = theMessage;

   }

   

   public String toString()

   {

       return sender + " texted " + receiver + ": " + message;

   }

}

4 0
2 years ago
Estoy haciendo codificación en este momento es tan confuso y no estar en la escuela es más difícil
Katarina [22]

Answer:

Misma

Explanation:

6 0
2 years ago
Read 2 more answers
Consumers affect which goods and services are produced because they _____.
arlik [135]

Answer:

Choice B, "choose which goods and services to buy"

Explanation:

Consumers choose which goods and services to buy. Companies only want to provide goods and services they know will be bought. Therefore, consumers affect which goods and services are produced because they choose which goods and services to buy.

3 0
2 years ago
Need help on this it’s the last one I need
BaLLatris [955]
Design a ringtone like it says
8 0
3 years ago
Other questions:
  • HELPPP ASAPP
    8·2 answers
  • The Windows Group Policy feature provides __________ that govern the way Windows operates in enterprise environments. a. a centr
    8·1 answer
  • Mia is attending a team meeting to discuss how to prevent accidents. One of her teammates suggests pushing all the desks against
    15·2 answers
  • define a function named quarter_num that has one parameter number and return quarter of the number. For example: if we called th
    7·1 answer
  • The most commnonly used OS is ___.<br> MS-DOS<br> Windows<br> Mac<br> Linux
    8·1 answer
  • Which of the following are input devices? Check all that apply.
    9·2 answers
  • Does anyone know a working free spotify premium on ios 2021 plz i have had any luck finding anything:(​
    15·2 answers
  • Help me with thissssss
    5·1 answer
  • The _____ describes how data actually moves from an application on one computer to an application on another networked computer.
    9·1 answer
  • a functional policy declares an organization's management direction for security in such specific functional areas as email, rem
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!