Calculate the hypotenuse of right angled triangle when other sides of the triangle are given in JAVA
CODING:
import javax.swing.JOptionPane;
class Triangle
{
public static void main(String[] args)
{
String x=JOptionPane.showInputDialog(null, "X of Triangle", "Input Number...", JOptionPane.QUESTION_MESSAGE);
String y=JOptionPane.showInputDialog(null, "Y of Triangle", "Input Number...", JOptionPane.QUESTION_MESSAGE);
int X=Integer.parseInt(x);
int Y=Integer.parseInt(y);
JOptionPane.showMessageDialog(null, "ANS:" + Math.sqrt(X*X+Y*Y));
System.exit(0);
}
}
class Triangle
{
public static void main(String[] args)
{
String x=JOptionPane.showInputDialog(null, "X of Triangle", "Input Number...", JOptionPane.QUESTION_MESSAGE);
String y=JOptionPane.showInputDialog(null, "Y of Triangle", "Input Number...", JOptionPane.QUESTION_MESSAGE);
int X=Integer.parseInt(x);
int Y=Integer.parseInt(y);
JOptionPane.showMessageDialog(null, "ANS:" + Math.sqrt(X*X+Y*Y));
System.exit(0);
}
}
Comments
Post a Comment