Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need code added to draw the bottom portion of the diamond import java.util.Scanner; /** * Program to draw a Diamond Shape * @author Jiju

I need code added to draw the bottom portion of the diamond

import java.util.Scanner;

/** * Program to draw a Diamond Shape * @author Jiju Poovvancheri (A00000000) */ public class DrawDiamond { public static void main(String[] args) { //Declare variables final int MIN_SIZE = 3; final int MAX_SIZE = 10; Scanner kbd = new Scanner(System.in); int h; System.out.println("" + "Draw Diamond " + "------------ " + "This program prints a diamond shape! " + "By Jiju Poovvancheri (A00000000) "); System.out.print("Please enter the height of the upper triangle: "); h = kbd.nextInt(); kbd.nextLine(); if (MIN_SIZE <= h && h <= MAX_SIZE) { System.out.println(); System.out.println("Diamond shape: "); // Upper triangle int numSpaces = h - 1; int numStars = 1; for (int i = 1; i <= h; ++i) { for (int j = 1; j <= numSpaces; ++j) { System.out.print(" "); } for (int j = 1; j <= numStars; ++j) { System.out.print("*"); } System.out.println(); --numSpaces; numStars += 2; } //TODO: draw the lower triangle } else { System.out.print(" " + "That's not a valid size. I can only do shapes " + "from " + MIN_SIZE + " to " + MAX_SIZE + ". " + "Quitting now. " + "Press enter..."); kbd.nextLine(); } }

}

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

More Books

Students also viewed these Databases questions

Question

What are some of the problems associated with recognition tests?

Answered: 1 week ago

Question

7. Identify four antecedents that influence intercultural contact.

Answered: 1 week ago

Question

5. Describe the relationship between history and identity.

Answered: 1 week ago