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 ...

View Replies


ADVERTISEMENT

Calculating Points On A Circle Using Radius

Oct 24, 2014

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;

[code]...

View Replies View Related

Two Circles Overlap If Distance Between Their Center Points Is Less Than Sum Of Their Radius

May 1, 2015

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;

[Code] ....

View Replies View Related

How To Get All Points In X And Y Coordinates Of Arc

Jul 4, 2014

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?

View Replies View Related

Asking User To Put In Radius Of A Circle To Calculate Area / Diameter And Circumference

Mar 5, 2014

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;

[Code] .....

View Replies View Related

How To Draw Points With Coordinates From Database

Jul 23, 2014

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.

View Replies View Related

Power Of Math - Calculate Volume Of A Cylinder By Asking User To Enter Height And Radius

Jan 29, 2015

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);
 
[Code] .....

View Replies View Related

Point With X And Y Coordinates - Display Difference Between Them

Apr 26, 2014

//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()

[Code] ....

View Replies View Related

Applets :: JApplet That Ask User For Points And Draw A Line From Said Points

Nov 6, 2013

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.

View Replies View Related

Bounding Of A Rectangle

Sep 17, 2014

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
}
}

View Replies View Related

GUI Program - Enter File Name And Display Text Area

Apr 14, 2014

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.

View Replies View Related

Ask User To Enter Number From 1 To 10 And Program Will Display Roman Numeral

Feb 6, 2014

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;
 
[Code] .....

View Replies View Related

Prompts User To Enter 5 Test Scores And Their Names - Calculate And Display Average

Sep 24, 2014

Using Bluejay. Need code that prompts user to enter 5 test scores and their names. Calculate the average and display.

First initial and last name , 5 test scores, and average

View Replies View Related

Area Of A Pentagon

Sep 7, 2014

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

[Code] ....

View Replies View Related

Area Of Regular Pentagon - End Result

Jul 17, 2014

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");

[Code] ....

View Replies View Related

User Enter A File On Text Field And Display Its Hex Representation In Text Area

Apr 17, 2015

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 {

[Code] .....

It's not doing anything, I don't understand why.

View Replies View Related

Enter In Sales Amount And Then Get It To Display Asterisk Per 100 In Sales

Apr 3, 2014

{
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.

View Replies View Related

Find Biggest Corner Based On Number Zero

Apr 23, 2014

The program should find the biggest corner, based on the number zero.

A zero becomes a corner when there's the same amount of zeros under it, and left to it.

The program should print a message saying what's the biggest corner size.

Corner size is the number of zeros inside it.

Java Code:

import java.util.*;
class Corners
{
static Scanner reader=new Scanner(System.in);
static final int N=25;
static int corners(int a, int b, int[][] m)

[Code] ....

That's the output:

Java Code:

The BOX:
1 0 0 1 1 1 0 1 0 1 0 0 1 0 0 0 1 0 0 0 0 0 1 1 1
1 0 1 0 1 0 0 1 0 0 0 1 0 1 1 1 0 1 0 0 0 1 1 1 0
0 1 1 1 1 1 0 0 0 0 0 0 0 1 1 0 0 1 1 0 0 1 0 0 0
0 1 0 1 0 1 1 1 1 1 1 0 0 0 1 1 0 0 1 1 0 1 0 0 1
0 0 1 1 0 0 0 0 0 1 0 0 0 0 1 0 0 1 0 0 0 0 1 1 0

[Code] ....

View Replies View Related

JavaFX 2.0 :: Round Corner In TableView Header

May 20, 2014

I'm doing a bit of styling in TableView. The result is quite nice but I can't make the left top corner round. This is the actual result:
 
[URL] ....
 
And this is the css :

.table-view {
    -fx-background-color: transparent;   
}
/*HEADER */
.table-view .column-header{      

[Code] .....

I would also like the top left corner was round.

View Replies View Related

Java Need To Enter 5 Grades And Can Only Enter 1 For Grade Conversion

Sep 13, 2014

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)

[Code] .....

View Replies View Related

Swing/AWT/SWT :: How To Put A JButton At Lower Right Corner Of JDialog With MigLayout

Jan 26, 2014

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.

View Replies View Related

Program Exits Even When Click No Or X Button On Upper Corner

Mar 31, 2015

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.

View Replies View Related

Radius Value Becoming Zero In Constructor

Jul 8, 2015

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.

View Replies View Related

Calculate Radius Of A Pond?

May 31, 2014

This is the code

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
" +

[Code] .....

View Replies View Related

Write Tester To Get Current Volume Of Balloon That Starts With A Radius Of 0

Oct 8, 2014

I am supposed to write a Tester to get the current volume of a balloon that starts with a radius of 0 after it is inflated.This is the balloon:

public class Balloon
{
 
private double savedRadius;//instance variable
 
/**constructor!!
Constructs a balloon with a radius
*/
}

[code]....

View Replies View Related

Properties Of A Triangle - X And Y Coordinates

Oct 29, 2014

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;

[Code] ....

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved