Enter Radius Of Bounding Circle And Display Coordinates Of Five Corner Points On Pentagon
May 29, 2014
(Corner point coordinates) Suppose a pentagon is centered at (0, 0) with one point at the 0 o’clock position. Write a program that prompts the user to enter the radius of the bounding circle of a pentagon and displays the coordinates of the five corner points on the pentagon. Here is a sample run:
Enter the radius of the bounding circle: 100
The coordinates of five points on the pentagon are
(95.1057, 30.9017)
(0.000132679, 100)
(-95.1056, 30.9019)
(-58.7788, -80.9015)
(58.7782, -80.902)
What we know , we know both the radius of the circle(user inputted) and the side of the pentagon from formula (double side = 2 * radius * Math.sin(Math.PI/5)) .We also know that one point is (0 .100) Also i know that the distance between 2 points is Math.sqrt(Math.pow(x1 - x2 ,2) - Math.pow(y1 -y2 ,2)) .
There might be other ways to solve it but this is my best bet trough i dont remember how to solve linear equations of the form x^2 + y^2 = - radius and radius ^2 = x^2 + (y - 100) ^ 2..
The solution i found is using the radius from the center to the point we want to find out and using the radius to the point we already know ( 0 .100) but i have to solve that damn equation first ...
I have to print points on a circle in increments of -0.1, but when I use a number larger than 1.3, the list stops at 0.1 larger than negRadius, and I don't know why. (Assume the center is (0,0))
public class PointsOnACircleV1 { public static void main(String[] args) { double radius = 1;
Write a program that draws 20 circles, with the radius and location of each circle determined at random...... Two circles overlap if the distance between their center points is less than the sum of their radii...
There may be many problems with the code in general but what I'm struggling with is the distance and the totalradius portion. Visually, its inaccurate.
import java.awt.*; import javax.swing.*; public class CircleTest extends JPanel { Circle []circles; Circle []circleCenter; Circle []all; private int distance, totalradius, dx, dy; private int radius,x,y;
I am planning a race simulator car and I have a problem to get the x and y coordinates from the graph (or circuit). I explain the problem better. If I for example, drawing an arc using the library DRAW2D how do I get all the points in x and y coordinates of that arc?
I am doing an assignment that is asking for the user to put in the radius of a circle and the program figures out the area, diameter and circumference. It is using 2 different java programs to accomplish this. One with the info on how to get area, diameter and circumference and one is the demo that runs the program. I keep getting errors on my demo.
// Circle Class public class Circle { private double rad; private double Pie; private double area; private double diameter;
I extracted columns from database and made calculations inside while loop. I know i need to make array to get from it coordinates for points. I want to draw them in interface created in another class but i have black hole and don't know how to get datas from while loop to array which is below.
How do you use power of math. I'm trying to write a calculator to calculate the volume of a cylinder by asking the user to enter the height and radius but when I use pow(2) it doesn't work. I imported java.lang.math class so i dont have to keep using math. for now my code runs just fine since I'm using radius * radius but I would really luv to use the power instead times each other when i have to use higher powers.
import java.util.Scanner; import static java.lang.Math.*; public class Lab2 { public static void main(String[] args) { Scanner scan = new Scanner(System.in);
//Design/write a class named MyPoint to represent a point with x and y coordinates. The class should contain:
//->Two variables, x and y, that represent the coordinates //->A no-arg constructor that creates a point (0,0) //->A constructor that constructs a point with specified coordinates //->Two getter (accessor) methods for the variables x and y //-> A method named distance that returns the distance from a point to another point of the MyPoint type //-> A method named distance that returns the distance from a point to another point with specified x and y coordinates. //Draw the UML Diagram for the class. Implement the class. Write a test program that creates two points (0,0) and (10, 30.5) and displays the distance between them.
I have written the program but not I have to do it with user input ....
class MyPoint { private double x; private double y; public double getx() { return x; } public double gety()
This is what he wants: He wants us to prompt the user to input x values and y values (that will be entered into an array when clicking one of the two buttons (this one will say: Add point)). When they click the second button (draw lines), it should take all the points and draw a line that connects all the points together using a method that we write. In the method we have to call the paint method up which the lines will be drawn. The lines drawn should be touching every point added. It shouldn't have parameters. It will also use Graphics painter = getGraphics(); We can't use frames either.
I have everything up until the method understood.
How to write a method that will draw a line from points inputted that is called up in the action listener when the second button (draw lines) is pressed.
I have to do the following: A bounding rectangle is the minimum rectangle that encloses a set of points in a two-dimensional plane. Write a method that returns a bounding rectangle for a set of points in a two-dimensional plane, as follows:
public static MyRectangle2D getRectangle(double[][] points)
The Rectangle2D class is defined in Programming Exercise 10.13. Write a test program that prompts the user to enter five points and displays the bounding rectangle's center, width, and height. Here is a sample run:
Enter five points: 1.0 2.5 3 4 5 6 7 8 9 10.The bounding rectangle's center (5.0, 6.25), width 8.0, height 7.5
This is my code so far, taking in account that Rectangle2D is already done in a previous problem.the thing is that i don't know if i have to erase public static void or do i leave it or how do i start it?
package theboundingrectangle; import java.util.Scanner; public static MyRectangle2D getRectangle(double[][] points) public class TheBoundingRectangle { public static void main(String[] args) { // TODO code application logic here } }
I have to write a gui program where I can enter a file name and then it gets displayed in a text area when I click Open. Conceptually, I do not get this. I was thinking of appending the text file into a string or something, but I guess I'm confused on how it all works and how I can open the text file. Not asking for the code, but just a compass or something.
I am trying to write a program that asks the user to enter a number from 1 through 10 and then the program will display the roman numeral for that number.
I am also adding a error message in which i haven't yet because im still trying to figure out how to the program will do the roman numeral.'
I have used the if and else if. but when i input a number it just repeats the number back to me.
The program cimpiles but it doesn't do what i want. here is what i have so far. how can i get the program to display the roman numeral after the number is entered.
import javax.swing.JOptionPane; public class Romannumeral { public static void main(String[] args) { double number;
I have to produce a program that gives the area of a pentagon. I'm very new to java so I get confused easily. I followed the formula in the textbook but I'm doing something wrong and I don't know what. This is the code I've written.
[import java.util.Scanner; public class Pentagon { public static void main(String[]args) { Scanner input = new Scanner (System.in); // Prompt for length
I am doing exercises which has to do with the area of regular pentagon.
(Geometry: area of a regular polygon) A regular polygon is an n-sided polygon in which all sides are of the same length and all angles have the same degree (i.e., the polygon is both equilateral and equiangular). The formula for computing the area of a regular polygon is :
I have checked errata on their page and they did not list the type-o under the final result.
Errata link [URL] ....
their result is Enter the number of sides: 5 Enter the side: 6.5 The area of the polygon is 74.69017017488385
and mine is Area of regular pentagon is 72.69017017488385
is it a code error?
import java.util.Scanner;
public class AreaOfAregularPolygon4_5 { public static void main (String[] args){ //Initiate scanner and use the input Scanner input = new Scanner (System.in); System.out.println(" Enter the number of sides in polygon");
I'm supposed to write a GUI application letting the user enter a file on the text field and display its hex representation in a text area and vice versa.
Here's my code:
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package hexconvertor; import java.util.*; import java.io.*; public class HexConvertor extends javax.swing.JFrame {
{ public static void main (String []args) { Scanner numberin = new Scanner (System.in); double store [];
[Code]....
How would I get my program to display a * for every 100 dollars in sales that the user enters in so: for example the user enters in store 1: $ 400 in sales for the store I want it to display store 1:****
The first part of my code allows the user to enter in whatever values the stores have in sales. The Second half of the code starts at line 19 is my best guess on what I need to do I just am not sure how to get it to display what I need it to.
How to improve my code. I finally was able to create a program that gives you the corresponding letter grade, when you enter in a numeric grade without using an array. The only issue left is that I have to be able to enter 5 grades at a time, and it give me the letter grade for all 5. I have the programming working, but only am able to enter 1 at a time. I am not sure what kind of loop or if I am supposed to use a loop.
public static void main(String[] args){ { int grade = 0; Scanner input = new Scanner(System.in); System.out.println("Enter : "); grade = input.nextInt(); if (grade >= 90)
With the MigLayout for Swing, I'd like to see the JDialog looking like the standard windows Dialog,where to have the OK and cancel buttons at the lower right corner.
Here is the snippet of code that is causing the problem
Java Code:
addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { int confirm = JOptionPane.showOptionDialog( VendorMachineSimulation.this, "Are You Sure you want to close this application?", "Exit Confirmation", JOptionPane.YES_NO_OPTION,
[Code] ....
My question is why does the snippet code at the top works in the class processAction but when I add to the main class that extends JFrame, it exits regardless if I click yes, no or the x button.
I am trying to create a user defined Exception. I am using a hard-coded value in the constructor of circle class at the time of object creation.But in the constructor this value becomes 0.
import java.lang.Exception; import javax.swing.*; class InvalidRadiusException extends Exception{ private double r; public InvalidRadiusException(double radius){ r = radius;
[Code] ....
Due to this its always generating InvalidRadiusException even if i am supplying a non-zero non-negative value.
public class PondRadius { public static void main (string[] args) { //Calculate the radius of a pond //which can hold 20 fish averaging 10 inches long int fishCount = 20;//number of fish in pond int fishLength = 10;// Average fish length int inchesPerFoot = 12;//number of inches in one foot
[Code] ....
And here is the error or exceptions i received
C:javaLesson1>javac PondRadius.java PondRadius.java:23: error: ')' expected System.out.println("To hold" + fishCount + fish averaging " + fishLength +" inch es long you need a pond with an area of " +
A triangle is defined by the x- and y- coordinates of its three corner points. Compute the following the following properties of a given triangle: the lengths of all sides, the angles at all corners, the perimeter and the area. The program must prompt a user for the point coordinates. I have created a class Triangle and a class TriangleSimulator, I am stuck and can't figure out why my program won't run correctly.
import java.util.Scanner; public class Triangle { Scanner in = new Scanner(System.in); private int x1; private int x2; private int x3;