In the following Java program replace conditions in while loops to produce Christmas tree output. import java.util.Scanner; public...

90.2K

Verified Solution

Question

Programming

In the following Java program replace conditions in while loopsto produce Christmas tree output.

import java.util.Scanner;

public class Tree

{

    public static void main(String[] args)

    {

        int size;

        Scanner scan = newScanner(System.in);

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

        size =scan.nextInt();

        int count = 0;

        while (__________)//??? condition

        {

           int len = 0;

           // print blanks

           while (____________)//??? condition

           {

               System.out.print(' ');

               len++;

           }

           len = 0;

           // print stars

           while (____________)//??? condition

           {

               System.out.print('*');

               len++;

           }

           System.out.println(); // go to next line

           count++;

        }

    }

}

Generated output for the size of 7:

Enter the size: 7

      *

     ***

    *****

   *******

*********

***********

*************

Answer & Explanation Solved by verified expert
4.3 Ratings (602 Votes)
Codeimport javautilScannerpublic class Treepublic static void mainString argsint sizeScanner scan new    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students