Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write Java Code. 3. Write a program that takes an input letter and outputs it in a diamond shape. Given a letter, it prints a

image text in transcribedimage text in transcribedimage text in transcribed

Write Java Code.

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': .B.B. C... ..A.. Diamond for letter 'E': ....... .D. ....D. .D.....D. ....... .8.3... 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 given 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 ..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_2

Step: 3

blur-text-image_3

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 In Depth Relational Theory For Practitioners

Authors: C.J. Date

1st Edition

0596100124, 978-0596100124

More Books

Students also viewed these Databases questions

Question

Compute the dot product. (i + j) (j + k)

Answered: 1 week ago

Question

=+ ^ What is the budget for this project?

Answered: 1 week ago

Question

What is a verb?

Answered: 1 week ago