Java 14 how to put numbers in a GUI
2 次查看(过去 30 天)
显示 更早的评论
hallo i am using eclips and whant to put numbers into a GUI but it wont let me.
this is my code (it keeps telling me to change the double a and b into a string but then i cant do maths maby it is to do with the JOptionPane.showInputDialog ) :

import javax.swing.JOptionPane;
public class test4 {
public static void main(String[] args) {
double c;
JOptionPane.showMessageDialog( null, "This will find out the hypotenuse of your triangle.");
double a = JOptionPane.showInputDialog("Enter Side A:");
double b = JOptionPane.showInputDialog("Enter Side B:");
c = Math.sqrt((a*a)+(b*b));
JOptionPane.showMessageDialog( null, "hypotenus:"+c);
}
}
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Java Package Integration 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!