Question: Write a test program that prompts the user to enter a side, a color, and a boolean value to indicate whether the triangle is filled.

Write a test program that prompts the user to enter a side, a color, and a boolean value to indicate whether the triangle is filled. The program should create a Hexagon object with this side, and set the color and filled properties using the input. The program should display the area, perimeter, color, and true or false to indicate whether it is filled or not. Repeat the prompt until the user enters a number less than or equal to zero. Your sample run should show at least three repetitions. Capture your execution and submit with your source code.

Algorithm

Open keyboard for input

Prompt user for side

While (side > 0)

Create a Hexagon object with the side value

Prompt the user for color

Set the color of the Hexagon object

Prompt the user for the value of filled (yeso)

Set the filled property of the Hexagon object

Print the string representation of the hexagon to the terminal

Prompt user for side

End While

Close input

My code so far:

Write a test program that prompts the user to enter a side,

import java.util.Scanner; public class TestHexagon { public static void main() { double side = 0; 7 /Open keyboard for input Scanner input = new Scanner (System.in); //Prompt user for side System.out.printf("Ener the side for Hexagon: "); side = input.nextDouble(); 7/While (side > 0) while(side >0) { 7/Create a Hexagon object with the side value 7/Prompt the user for color System.out.printf("Enter the color for Hexagon"); String color = input.next(); // Set the color of the Hexagon object 7/Prompt the user for the value of filled (yeso) System.out.printf("Is the Hexagon filled? Yes/No: "); // Set the filled property of the Hexagon object 7/Print the string representation of the hexagon to the terminal 7/Prompt user for side } //End While //Close input input.close()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!