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
jeka94
3 years ago
10

Write code which takes two inputs from the user, a number of sides followed by a side length, then creates a regular polygon wit

h that number of sides and side length.Sample run:Type the number of sides:8Type a side length:7.5regular octagon with side length 7.5Hint: Make sure you use the right data types when taking user input.
Computers and Technology
2 answers:
SVETLANKA909090 [29]3 years ago
8 0

Answer:

import java.util.Scanner;

public class Polygon {

       public static void main(String[] args) {

               Scanner sc = new Scanner(System.in);

               System.out.println("Type the number of sides:");

               int sides = sc.nextInt();

               System.out.println("Type a side length:");

               double length = sc.nextDouble();

               if (sides== 5){

                      System.out.println("Pentagon, length "+length);

               } else if (sides == 6){

                      System.out.println("Hexagon, length "+length);

               } else if (sides == 7){

                      System.out.println("Heptagon length "+length);

               } else if (sides == 8){

                       System.out.println("Octagon, length "+length);

                } else if (sides == 9){

                       System.out.println("Nonagon, length "+length);

                 } else if (sides == 10){

                       System.out.println("Decagon, length "+length);

} else if (sides == 11){

                       System.out.println("Undecagon, length "+length);

} else if (sides == 12){

                       System.out.println("Dodecagon, length "+length);

} else {

                       System.out.println("Please choose a valid number.");

               }

       }

}

Explanation:

The Java source code defines a class called 'Polygon' the main method of the class prompts for user inputs for the sides and length variables. The nested if-statement prints the type of polygon with respect to the number of sides.

Ahat [919]3 years ago
5 0

Answer:

i need free point sorry lol

Explanation:

You might be interested in
Write a class named Add that has the following data members, constructor, and methods:
taurus [48]

Answer:

A class is like a blueprint of object.

Explanation:

A class defines the kinds of data and the functionality their objects will have.

A class enables you to create your own custom types by grouping together variables of other types, methods and events.

In C#, we can create a class  using the class keyword.

Here's a sample program:

using System;

namespace ConsoleApplication

{

   public class Test

   {

       public static void Main()

       {

           Add a1 = new Add(70, 50);

           a1.AddNumbers();                    

           Console.ReadLine();

       }      

   }

     class Add

   {

       private int row;

       private int column;

       public Add(int r, int c)

       {

           row = r;

           column = c;

       }

       public void AddNumbers()

       {

           Console.WriteLine(row+column);

       }

   }

}

output: 120

Explanation of the program:

I have created a class named Add. Within a class, row and column are two fields and AddNumbers() is a method. We also have constructor to initialize row and column.

In main method, If I need to invoke members of the class, I must create  an instance of the class. We can create any number of instances using the single class.IN our program, a1 is the reference variable using which we can invoke members of the class. I invoked function in the class and passed arguments to the constructor while creating an instance.

Those values are assigned to method variables and it operated the addition. Thus the output is 120.

7 0
3 years ago
even if we reach that state where an AI can behave as human does,how do we measure if AI is acting like a human?
xxTIMURxx [149]

A person can be able to measure if AI is acting like a human by the use of   Turing test.

<h3>How do we measure of artificial intelligence is acting like a human?</h3>

One can measure if AI is  Acting humanly via the use of a human who is said to interrogates the program and also the use of another person through the use of a terminal simultaneously.

Note that If after some amount of time or period, the interrogator is said to be unable to tell which is which, the program is said to have passed. To pass this test it is one that needs natural language processing.

Hence, A person can be able to measure if AI is acting like a human by the use of Turing test.

Learn more about AI from

brainly.com/question/25523571

#SPJ1

4 0
1 year ago
Where does the list of incoming mail appear in gmail
k0ka [10]
In your inbox,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,..,.,
5 0
4 years ago
Read 2 more answers
What does aerodynamics mean?
murzikaleks [220]
Having a shape that reduces the drag from the air moving past.
3 0
3 years ago
Read 2 more answers
One of the most common uses of spreadsheet programs are communicating with others. O editing images and photos. O tracking and m
Mama L [17]

Answer:        tracking and manipulating data.

Explanation: A spreadsheet is nothing more than a large ledger like the ones accountants and office workers used years ago. It was a ruled paper that data and information was entered on in order to keep track of money, inventory, and other information.  Adding or subtracting from one column would change the totals and values overall. Now, with computers we have the electronic version and store the data on disc, flash drive or other connected media.

8 0
3 years ago
Read 2 more answers
Other questions:
  • Maurice has just purchased his first computer, which contains a preinstalled suite of basic software applications. He receives a
    8·2 answers
  • Which of the following represent typical account fees?
    7·1 answer
  • If the value of the expression,
    13·1 answer
  • What is the purpose for adding images and graphics to a web page?
    5·1 answer
  • For the recursive method below, list the base case and the recursive statement, then show your work for solving a call to the re
    8·1 answer
  • Is the color grade of black or white higher?
    11·2 answers
  • If we assume the modern view of existential import, why is the following syllogism invalid? No computer is made of clay. All com
    15·1 answer
  • C++Assign to maxSum the max of (numA, numB) PLUS the max of (numY, numZ). Use just one statement. Hint: Call FindMax() twice in
    8·1 answer
  • Antivirus is a program that detects error.True or False.​
    9·1 answer
  • Expalin the defference between the driver of a desktop and a laptop​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!