为什么报scanner错误??

攻城狮AndLi 2009-09-14 08:20:08
package com.javabook.cho2;
import java.util.*;

public class Equation {
public static void main(String []args)
{
Scanner s=new Scanner(System.in);
System.out.println("请输入a:");
float a=s.nextFloat();
System.out.println("请输入b:");
float b=s.nextFloat();
System.out.println("请输入c:");
float c=s.nextFloat();
double delta=b*b-4*a*c;
if(delta>0)
{
double x1=(-b+Math.sqrt(delta))/(a*2);
double x2=(-b-Math.sqrt(delta))/(a*2);
System.out.println("方程的两个不同实根:");
System.out.println("x1="+x1);
System.out.println("x2="+x2);
}
else if(delta==0)
{
double x1=(-b)/(2*a);
double x2=x1;
System.out.println("x1="+x1);
System.out.println("x2="+x2);
}
else
{
System.out.println("无解!!");

}
}

}
错误提示:
java.lang.Error: Unresolved compilation problems:
Scanner cannot be resolved to a type
Scanner cannot be resolved to a type

at com.javabook.cho2.Equation.main(Equation.java:7)
Exception in thread "main"
...全文
232 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
攻城狮AndLi 2009-09-14
  • 打赏
  • 举报
回复
谢谢了!!
shiyiwan 2009-09-14
  • 打赏
  • 举报
回复
1.5以下的jdk中还没有Scanner这个类
攻城狮AndLi 2009-09-14
  • 打赏
  • 举报
回复
是的
shiyiwan 2009-09-14
  • 打赏
  • 举报
回复
JDK版本是否在1.5以下?

58,454

社区成员

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

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