标题:可以帮我看一个小applet吗?
取消只看楼主
想你的天空
Rank: 2
等 级:新手上路
威 望:5
帖 子:610
专家分:0
注 册:2004-12-30
 问题点数:0 回复次数:1 
可以帮我看一个小applet吗?
import java.awt.Graphics ;
import javax.swing.JApplet ;
import javax.swing.JOptionPane;
public class Float extends JApplet{
public void paint(Graphics g)
{
  String firstNumber;
  String secondNumber;
  String thirdNumber;
  float   first;
  float   second;
  float   third;
  float   sum,average,mul,max,min;
  firstNumber = JOptionPane.showInputDialog("Enter first number");
  secondNumber = JOptionPane.showInputDialog("Enter second number");
  thirdNumber = JOptionPane.showInputDialog("Enter third number");
//     number1 = Integer.parseInt(firstNumber);//把String转换成int
  first = Float.parseFloat(firstNumber);
  second = Float.parseFloat(secondNumber);
  third = Float.parseFloat(thirdNumber);
  sum = first + second + third;
  average = sum/3;
     if((second>first)&&(second>third))  max = second ;
       else if((second>first)&&(second<third))  max = third ;
      else max = first ;
     
     if((second<first)&&(second<third))  min = second ;
       else if((second<first)&&(second>third)) min = third ;
      else min = first ;   
      mul = first * second * third ;
      
      JOptionPane.showMessageDialog(null,"max = " + max ,"\nmin = "+ min "\naverage = "+average "\nmul = "+ mul,"VC++.NET",JOptionPane.PLAIN_MESSAGE);
                    
      System.exit(0);
}
}
//firstNumber = JOptionPane.showInputDialog("Enter first number");  编译器指示这里出错
// number1 = Integer.parseInt(firstNumber);//把String转换成int   //这是书上的对的例子

[此贴子已经被作者于2005-9-19 9:45:08编辑过]


搜索更多相关主题的帖子: applet 
2005-09-19 09:34
想你的天空
Rank: 2
等 级:新手上路
威 望:5
帖 子:610
专家分:0
注 册:2004-12-30
得分:0 
import java.awt.Graphics ;
import javax.swing.JApplet ;
import javax.swing.JOptionPane;
public class Float1 extends JApplet{
 public void init()
 {
  String firstNumber;
  String secondNumber;
  String thirdNumber;
  float   first;
  float   second;
  float   third;
  float   sum,average,mul,max,min;
  firstNumber = JOptionPane.showInputDialog("Enter first number");
  secondNumber = JOptionPane.showInputDialog("Enter second number");
  thirdNumber = JOptionPane.showInputDialog("Enter third number");
  
  first = Float.parseFloat(firstNumber);
  second = Float.parseFloat(secondNumber);
  third = Float.parseFloat(thirdNumber);
  sum = first + second + third;
  average = sum/3;
  
     if((second>first)&&(second>third))  max = second ;
       else if((second>first)&&(second<third))  max = third ;
      else max = first ;
     
     if((second<first)&&(second<third))  min = second ;
       else if((second<first)&&(second>third)) min = third ;
      else min = first ;   
      mul = first * second * third ;
      
        String str = new String("max = " + max + "\nmin = " + min + "\naverage = "+average + "\nmul = "+ mul);
        String title = "VC++.NET";
        JOptionPane.showMessageDialog(null,str,title,JOptionPane.PLAIN_MESSAGE);
     }
     public void paint(Graphics g)
     {
      super.paint(g);
        System.exit(0);
  }
}

//这样行,  不过修改后的用html打开,还是原来的那个

2005-09-20 09:10



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-28007-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.073495 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved