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
You have been asked to replace a cracked screen on a laptop. The replacement screen was delivered today, but it did not include
RoseWind [281]

Answer:

D

Explanation:

Its probably your best bet all the other ones seem fishy.

4 0
2 years ago
Doug grew up on a large farm in southwest Wisconsin. As a college graduation gift, Doug’s father gave him several hundred acres
IrinaVladis [17]

Answer: Sole Proprietorship.

Explanation:

This question wants to know what type of business is described in the scenario.

In a Sole Proprietorship, the owner of the business is essentially the business itself. They control all aspects of the business from the operating activities to the financial activities of the firm. This is usually the first stage business type in an entrepreneurship.

The definition of a sole proprietorship above fits with what Doug does. Doug is the owner of the farming business and seems to be handling all aspects of it by himself. This would therefore make it a sole proprietorship.

5 0
3 years ago
Advantages of email over traditional mail​
dalvyx [7]

Answer: emails are delivers very fast compared to regular traditional mail

Explanation:

6 0
1 year ago
How long is prison time for someone who commits copyright infringement for the first time ?
Murljashka [212]

Answer:

it is up to 5 years

Explanation:

7 0
3 years ago
This is not school related in anyway but. I used to play this videogame on my computer years ago, but i cannot remember the name
Taya2010 [7]
Cat Quest possibly? How long ago? i remember playing many. I LOVE CATS.
4 0
3 years ago
Read 2 more answers
Other questions:
  • Network and web0based software used for workplace collaboration is commonly called?
    11·1 answer
  • The disk drive is a secondary storage device that stores data by _____ encoding it onto a spinning circular disk.
    14·1 answer
  • The expectations I would discuss with Erica regarding the usage of the internet
    6·1 answer
  • A(n) ____ is a logical grouping of several data files that store data with similar characteristics.
    8·1 answer
  • What are the similarities between data mining and data analytics
    11·1 answer
  • Find the simple interest Jay owes on a five-year student loan of $48,000 with an annual interest rate of 5%.
    6·1 answer
  • Output is the act of is the act of entering the data to the computer?​
    10·1 answer
  • Backup software creates backups and prevents you from losing all your data, so would backup software be considered an applicatio
    7·1 answer
  • Lucy wants to access the webpage. She is using her computer to access the webpage. What types of information will be in one fram
    11·1 answer
  • Technical safeguards involve the hardware and software components of an information system. group of answer choices true false
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!