Vinay Naga

Greenhorn
+ Follow
since May 16, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Vinay Naga

I have tried using JavaFx plugin for Eclipse. I faced a problem while getting it to work. I had to change over to NetBeans. If you use NetBeans you do not have to worry about adding plugins. You can select the JavaFx package and it comes ready with NetBeans.
15 years ago
Hi , I have two jdks 1.5 and 1.6. When I enable the jdk 1.5 to be active for IE, I can see JRE 1.5 in Java section of advanced tab of IE. However when I launch the app the Java Console opens up but the version is Java Plug-in 1.6.0_06. How do I get the console to be Java Plug-in 1.5 ?
Please advise.

Thanks for your help,
Vinay
16 years ago
I have a Mathematical equation that cannot be solved linearly. Can some one help me find a simple logic to calculate yield.

Given a financial instrument which offers the annual payments

Years from NowPromised Annual Payments
1$2,000=c1
2$2,000=c2
3$2,500=c3
4$4,000=c4

The price of the financial instrument is :$7,704=P
Use the equation below to calculate the yield y:

P = (c1/((1+y)^1)) + (c2/((1+y)^2)) + (c3/((1+y)^3)) + (c4/((1+y)^4))
where P, c1, c2, c3, and c4 are above
and y is the yield of the financial instrument

Find the yield y which satisfies the above equation.

Write a JAVA console or windows program to do this.
Input :
input for c1
input for c2
input for c3
input for c4
input for price

Output:
yield y

There has to be a way to start from the approx. value. I need some advice on this.

Thanks for your help,
Vinay
17 years ago
Thanks Jeanne, Rob and Vilmantas.
Yes, I need to create something like a point class. And the order of the elements in each of the points is also important. Let me post the actual problem and the solution I came up with. But it is not complete because It still fails with respect to the order. i.e. The points {10,50} and {50,10} are treated same in my code, which is wrong.

Problem :
===================
Shape A defined by a set of (x,y) points in the cartesian xy - plane.
Shape B defined by a set of (x,y) points in the cartesian xy -plane which creates a hollow hole inside of shape A.
Shape C defined by a set of (x,y) points in the cartesian xy-plane.
Write a JAVA console or windows program to find Shape E. E is the intersection of shape C with shape A where A has a hole shape B.
E is a set of (x,y) points in the cartesian xy - plane.

Input of program:
Input for A e.g. (Ax1,Ay1), (Ax2,Ay2), (Ax3,Ay3)�
Input for B e.g. (Bx1,By1), (Bx2,By2), (Bx3,By3)�
Input for C e.g. (Cx1,Cy1), (Cx2,Cy2), (Cx3,Cy3)�
Ouput of program :
Output for E e.g. (Ex1,Ey1), (Ex2,Ey2), (Ex3,Ey3)�

Please provide all code.
===================================

Solution code , which I am still working on. Also bear with me for the mistakes. Please feel free to correct it.
=====================================
import java.util.ArrayList;


public class programone
{
String Shape;
ArrayList<Integer> shapeA = new ArrayList<Integer>();
ArrayList<Integer> shapeB = new ArrayList<Integer>();
ArrayList<Integer> shapeC = new ArrayList<Integer>();
int arrayA[][] = {{100,50},{300,500}, {25, 45},{0,0}};
int arrayB[][] = {{100,50}};
int arrayC[][] = {{40,40},{100,50},{300,500}, {50, 100}, {0,0}};
int k=0;
int l=0;
int m=0;



public static void main(String args[]){
programone p1 = new programone();
p1.logic();
}

public void logic(){

for (int i = 0 ; i < arrayA.length ;i ++ )
{
for (int j =0 ; j <2 ; j ++,k++)
{
shapeA.add(k,arrayA[i][j]);
}
}
for (int i = 0 ; i < arrayB.length ;i ++ )
{
for (int j =0 ; j <2 ; j ++,l++)
{

shapeB.add(l,arrayB[i][j]);
}
}
for (int i = 0 ; i < arrayC.length ;i ++ )
{
for (int j =0 ; j <2 ; j ++,m++)
{
shapeC.add(m,arrayC[i][j]);
}
}

shapeA.removeAll(shapeB);
shapeC.retainAll(shapeA);

System.out.println("ShapeC has a resultant set : " + "{");
for (int y=0; y < shapeC.size(); y ++ )
{
if (y % 2 ==0)
{
System.out.println("{" + shapeC.get(y)
+","+ shapeC.get(y +1)+"}," );
}
}
System.out.println("}");
}
}
17 years ago
Hi,

I am trying write a program that has three sets with points defined by
Set A = {{x1, y1}, {x2, y2},{x3, y3} ...}
Set B = {{x1, y1}, {x2, y2}}
Set C = {{x2,y2},{x3,y3},{x4,y4},....}

I need to get the elements of the set such that ((A-B)intersection(C))

I have written the following program

public class sample {
HashSet<int[][]> shapeA = new HashSet<int[][]>();
HashSet<int[][]> shapeB = new HashSet<int[][]>();
HashSet<int[][]> shapeC = new HashSet<int[][]>();
int arrayA[][] = {{0,0},{100,50},{300,500}, {50, 100}, {0,0}};
int arrayB[][] = {{0,0},{100,50}};
int arrayC[][] = {{40,40},{50,100},{300,500}, {50, 100}, {40,40}};
int resultant[][] ;
Iterator<int[][]> resultantarray ;

public static void main(String args[]){
sample sam = new sample();
sam.logic();
}

public void logic(){

shapeA.add(arrayA);
shapeB.add(arrayB);
shapeC.add(arrayC);

shapeA.removeAll(shapeB);

shapeC.retainAll(shapeA);

resultantarray = shapeC.iterator();

while (resultantarray.hasNext())
{
resultant = resultantarray.next();
}

for (int i = 0 ; i < resultant.length; i ++)
{
System.out.println(resultant[i][0]);
}
}
}


But when I inspect (am using Eclipse) the variables in this line :

shapeA.removeAll(shapeB);

The HashSet shapeA does not seem to remove the points in HashSet shapeB. I see all the variables in shapeA as it is. Please let me know what I am doing wrong here.

Thanks for your help,
Vinay
17 years ago
I am new to this , I just tried the same program. Is it because , the DatagramSocket tries to send packets through the firewall and does it take some time to send thru it ?