1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
IrinaK [193]
2 years ago
13

Edhesive unit 2 lesson 5 coding activity 1 Write code which creates three regular polygons with 11, 14 and 19 sides respectively

. All side lengths should be 1.0. The code should then print the three shapes, one on each line, in the order given (i.E. The one with 11 sides first and the one with 19 sides last). Sample run: regular hendecagon with side length 1.0 regular tetrakaidecagon with side length 1.0 regular enneadecagon with side length 1.0
Computers and Technology
1 answer:
SVEN [57.7K]2 years ago
4 0

Answer:

public class Polygon {

   private String name;

   private int sides;

   private double sideLength;

   public Polygon(String name, int sides, double sideLength) {

       if (sideLength <= 0) throw new IllegalArgumentException("Length cannot be zero or negative.");

       if (sides <= 0) throw new IllegalArgumentException("Sides cannot be zero or negative.");

       this.name = name;

       this.sides = sides;

       this.sideLength = sideLength;

   }

   public String getName() {

       return name;

   }

   public void setName(String name) {

       this.name = name;

   }

   public double getSideLength() {

       return sideLength;

   }

   public void setSideLength(double sideLength) {

       if (sideLength <= 0) throw new IllegalArgumentException("Length cannot be zero or negative.");

       this.sideLength = sideLength;

   }

   public int getSides() {

       return sides;

   }

   public void setSides(int sides) {

       this.sides = sides;

   }

   (use the at sign here)Override

   public String toString() {

       return "regular " + name + " with side length " + String.format("%.1f", sideLength);

   }

}

public class TestPolygon {

   public static void main(String[] args) {

       Polygon sides11 = new Polygon("hendecagon", 11, 1);

       Polygon sides14 = new Polygon("tetrakaidecagon", 14, 1);

       Polygon sides19 = new Polygon("enneadecagon", 19, 1);

       System. out. println(sides11);

       System. out. println(sides14);

       System. out. println(sides19);

   }

}

Explanation:

This java source code defines a class that creates a regular polygon based on the number of sides given to it.

Below is a screenshot of the program code and output.

You might be interested in
What are several networks connected together using a router
elixir [45]

Answer:

local Area Network, Wide Local Area Network and Personal Area Network

8 0
2 years ago
What was the first carbonated drink to be introduced in the US?
adelina 88 [10]
Taco bell...........................................................................................................................................................................

6 0
2 years ago
You are the administrator for the contoso.com website. recently, the server hosting the website had a failure that caused it to
Alisiya [41]
Protecting the Power supply
Adding disk Arrays
Install an NLB Cluster
4 0
3 years ago
Which characteristic of a company suggests that it has an informal work culture?
goldenfox [79]
The main characteristic of a company with suggests that it operates with an informal work culture is flexible working hours. With this kind of work culture, <span>workers are allowed to alter their workday start and finish times; and are not required to strictly follow the traditional work arrangements of the standard 9 a.m. to 5 p.m</span>
6 0
3 years ago
Create a visual python quiz that pops up when you run the code
Irina-Kira [14]

Refer to the attachment!!

8 0
2 years ago
Other questions:
  • Finding your style in photography is about ___
    10·2 answers
  • Sara has a habit of stealing money from her brother Charlie. When he found out, Charlie rebuked Sara in the presence of his frie
    11·1 answer
  • Windows on the desktop are just one of many objects used in a graphical user interface (GUI)-- buttons, drop-down list boxes, po
    7·1 answer
  • To view paragraph marks, click on the ______ tab, in the paragraph group, click show/hide
    11·1 answer
  • What are the data types used in C programming with examples
    5·1 answer
  • Write a program that reads a list of integers, and outputs those integers in reverse. The input begins with an integer indicatin
    10·1 answer
  • What is a correlation and how does it relate to inferential error?
    5·1 answer
  • How can you tell that you're driving in the right direction?
    14·1 answer
  • A host is on the 192.168.146.0 network that has a subnet mask of 255.255.255.0. The binary value of the host portion is 11010101
    8·1 answer
  • The _____ constraint assigns a value to an attribute when a new row is added to a table
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!