Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java PLEASE DO NOT REUSE OLD CODE WRITE NEW CODE AND THUMBS UP WILL BE PROMISELY GIVEN. PROGRAM MUST HANDLE INVALID INPUTS 3. Write a

Java

PLEASE DO NOT REUSE OLD CODE WRITE NEW CODE AND THUMBS UP WILL BE PROMISELY GIVEN.

PROGRAM MUST HANDLE INVALID INPUTS

image text in transcribed

image text in transcribed

image text in transcribed

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 Input

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David J. Auer

3rd Edition

0131986252, 978-0131986251

More Books

Students also viewed these Databases questions

Question

Does your team seem to be accomplishing less?

Answered: 1 week ago