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]
3 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]3 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
Isabella is a security support manager for a large enterprise. In a recent meeting, she was asked which of the standard networki
HACTEHA [7]

Answer:

A. Router

Explanation:

4 0
3 years ago
How can an attacker execute malware through a script?
Anvisha [2.4K]

Answer:

An attacker can attach a script to a program that you download which then infects your computer.

5 0
2 years ago
How to break and argument at a certain symbol in python.
Dima020 [189]

Answer:push both of the people away from each other and try to solve things out

Explanation:

3 0
2 years ago
Cual es la funcion del procesador resumen porfa
Arisa [49]

Answer:

todavia necesitas ayuda

7 0
3 years ago
Pleaseeeee help <br> Can HTML be used to create a complicated mobile application? <br> True or false
puteri [66]
Yes but the caliber of code required is inefficient compared to other languages.
5 0
3 years ago
Read 2 more answers
Other questions:
  • A half-life is the amount of time it takes for a substance or entity to fall to half its original value. Caffeine has a half-lif
    11·1 answer
  • Type the correct answer in the box spell all words correctly
    8·1 answer
  • Ok so another weird question! So if you know what google drive is and how to upload a video why does it keep adding hours! it ke
    11·1 answer
  • What is labor and how does it relate to automobile!!!! NEED HELP PLEASEE
    13·1 answer
  • Yesterday you installed a new game on your computer. When you ran the computer, you noticed that the application was running ver
    15·1 answer
  • Which function returns a valid value without any arguments?
    14·2 answers
  • Question 7 of 10
    13·1 answer
  • According to institutional anomie theory, why is there a need to maintain cooperation between economic and non-economic institut
    9·1 answer
  • BOTH QUESTIONS ONLY FILL IN C++ CODEWrite a copy constructor for CarCounter that assigns origCarCounter.carCount to the construc
    12·1 answer
  • Given the tables PRODUCT (ProductID. Description. Cost) SUPPLIER (Supplier D. ContactName, Phone Number) as shown in the figure
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!