初学者问题跪求大仙解答

yqm925 2012-05-31 10:18:22
//JAVA大学教程2.12 开发一个JAVA applet,确定一个商店的客户是否已超过其信用卡透支数
客户提供的信息:帐号,本月初余额,该客户所购置所有商品总额,本月该客户账号中的存款总额,允许的信用卡限额
下面是我编写的一个程序,现在我想输入的是浮点型的数据,但是老报错,求大仙指教,我是初学者
import java.awt.*;
import java.applet.Applet;

public class Creditcard extends Applet{
Label prompt1,prompt2,prompt3,prompt4,prompt5;
TextField input1,input2,input3,input4,input5;
double count,left_money,gift_sum,deposit_sum,credit_limit,new_left;


public void init()
{
prompt1 = new Label("enter your count number:");
input1 = new TextField(10);
prompt2 = new Label("enter your count left money:");
input2 = new TextField(10);
prompt3 = new Label("enter your total gift cost:");
input3 = new TextField(10);
prompt4 = new Label("enter your deposit:");
input4 = new TextField(10);
prompt5 = new Label("enter your credit limit:");
input5 = new TextField(10);
add(prompt1);
add(input1);
add(prompt2);
add(input2);
add(prompt3);
add(input3);
add(prompt4);
add(input4);
add(prompt5);
add(input5);
}

public void paint(Graphics g)
{
g.drawString("the new left money is:"+new_left,100,180);
if(new_left>credit_limit)
g.drawString("Credit limit exceeded", 100, 200);
}



public boolean action(Event event,Object o)
{
if(event.target==input5)
{
count = Integer.parseInt(input1.getText());
left_money = Integer.parseInt(input2.getText());
gift_sum = Integer.parseInt(input3.getText());
deposit_sum = Integer.parseInt(input4.getText());
credit_limit = Integer.parseInt(input5.getText());
new_left = -left_money+gift_sum-deposit_sum;
repaint();

}
return true;
}





}
...全文
42 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
yqm925 2012-05-31
  • 打赏
  • 举报
回复
原来如此 多谢多谢
sdojqy1122 2012-05-31
  • 打赏
  • 举报
回复
解析double 是Double.parseDouble(String s);
解析float Float.parseFloat(String s);
解析Long 是Long.parseLong(String s);

23,405

社区成员

发帖
与我相关
我的任务
社区描述
Java 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧