Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a program that receives one integer n, and prints a number of stars based on that, putting one star in the first line, two
Write a program that receives one integer n, and prints a number of stars based on that, putting one star in the first line, two in the second line, , and n in the nth line. And then n-1 in line (n+1), n-2 in line (n+2), ,,, , and finally 1 in line (2*n - 1).
For example, if the input is 5, the output should be:
* ** *** **** ***** **** *** ** *
Or when input is 10, the output should be:
* ** *** **** ***** ****** ******* ******** ********* ********** ********* ******** ******* ****** ***** **** *** ** *
import java.util.Scanner;
public class Main { public static void main(String[] args) { Scanner scnr = new Scanner(System.in);
/* Type your code here. */ } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started