17.Write a Java program that prompts the user to input an integer greater than 0 which represents the size/height of the triangle shape. The program should print the following triangle shape according to the user input by alternating 'l' and '+' characters. Invalid error message must be displayed if the size is less than 1. Example: if the size of the shape = 4, then the program should output: 1 1+1 1+1+1 1+1+1+1

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 30PE
icon
Related questions
Question
17.Write a Java program that prompts the user to input an integer greater than 0 which represents the size/height of the
triangle shape. The program should print the following triangle shape according to the user input by alternating 'f' and
'+' characters. Invalid error message must be displayed if the size is less than 1.
Example: if the size of the shape = 4, then the p program
should output:
!
!+!
!+!+!
1+1+1+1
Transcribed Image Text:17.Write a Java program that prompts the user to input an integer greater than 0 which represents the size/height of the triangle shape. The program should print the following triangle shape according to the user input by alternating 'f' and '+' characters. Invalid error message must be displayed if the size is less than 1. Example: if the size of the shape = 4, then the p program should output: ! !+! !+!+! 1+1+1+1
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning