Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Java Eclipse PLEASE WRITE NEW CODE DO NOT REUSE 3. Write a program that takes an input letter and outputs it in a diamond shape.
Java Eclipse
PLEASE WRITE NEW CODE DO NOT REUSE
3. Write a program that takes an input letter and outputs it in a diamond shape. Given a letter, it prints a diamond starting with 'A', with the supplied letter at the widest point. Your program should satisfy the following requirements: The first row contains one 'A'. The last row contains one 'A'. All rows, except the first and last, have exactly two identical letters. The diamond is horizontally symmetric. The diamond is vertically symmetric. The diamond has a square shape (width equals height). The letters form a diamond shape. The top half has the letters in ascending order. The bottom half has the letters in descending order. Examples In the following examples, spaces are indicated by - characters. Diamond for letter 'A': A Diamond for letter 'C': ..A.. .B.B. C...C .B.B. ..A.. Diamond for letter 'E': ...A.... ...B.B... .D.....D. E.......E .D. ....D. ..C...c.. ...B.B... ....A.... Your program must have the following methods: public static void main(String[] args) Main method will take the input letter from the user. Then, it will invoke constructDiamond() method. Lastly, it will invoke printDiamond() method. public static char[] [] constructDiamond (char letter) This method should take a char letter and construct the diamond shape for the giver letter in a two dimensional char array. The size of your two dimensional array is determined based on the given letter. This method should return the two dimensional array to the main() method public static void printDiamond (char[] [] diamond) This method should take a two dimensional char array and print the content of it. Example Run 1 Enter a Letter: 7 Invalid Input ! Example Run 2 Enter a Letter: Invalid Input ! Example Run 3 Enter a Letter: A A Example Run 4 Enter a Letter: C ..A.. .B.B. | C...C .B.B. ..A.. Example Run 5 Enter a Letter: d ...A... ..B.B.. .c...c. D.....D .c...c. ..B.B.. ..A... Example Run 6 Enter a Letter: AC Invalid InputStep 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