java-哪位大神帮忙解决一下Keyboard cannot be resolved的问题

问题描述

哪位大神帮忙解决一下Keyboard cannot be resolved的问题

具体代码如下
package Students;
import java.sql.*;
import java.util.ArrayList;
public class Test
{
private String id;
private String name;
private int math;
private int english;
private int java;
private int computer;

   public String getId()
   {
          return id;
   }

   public void setId(String id)
   {
          this.id = id;
   }

   public String getName()
   {
          return name;
   }

   public void setName(String name)
   {
          this.name = name;
   }

   public int getMath()
   {
          return math;
   }

   public void setMath(int math)
   {
          this.math = math;
   }

   public int getEnglish()
   {
          return english;
   }

   public void setEnglish(int english)
   {
          this.english = english;
   }

   public int getJava()
   {
          return java;
   }

   public void setJava(int java)
   {
          this.java = java;
   }

   public int getComputer()
   {
          return computer;
   }

   public void setComputer(int computer)
   {
          this.computer = computer;
   }

   public static void main(String[] args) throws Exception
   {
          String id;
          String cid;
          String name;
          int math;
          int english;
          int java;
          int computer;
          String DBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
          String conStr = "jdbc:odbc:student";
          Connection con = null;
          Statement stmt = null;
          ResultSet rs = null;
          Class.forName(DBDriver);
          con = DriverManager.getConnection(conStr, "student", "123");
          stmt = con.createStatement();
          String s = "nnttt学 生 成 绩nntt 1 新 增ntt 2 更 改ntt 3 删 除ntt 4 查 找ntt 5 显 示ntt 0 退 出nn";
          System.out.print(s);
          int choice = Keyboard.getInteger();
          switch (choice)
          {

                 // 添加学生
                 case 1:
                        System.out.print("请输入学生信息n");
                        System.out.print("学号:");
                        id = Keyboard.getString();
                        System.out.print("姓名:");
                        name = Keyboard.getString();
                        System.out.print("数学:");
                        math = Keyboard.getInteger();
                        System.out.print("英语:");
                        english = Keyboard.getInteger();
                        System.out.print("JAVA:");
                        java = Keyboard.getInteger();
                        System.out.print("计算机:");
                        computer = Keyboard.getInteger();
                        stmt.executeUpdate("insert into lxh1 values('" + id + "','"
                                      + name + "','" + math + "','" + english + "','" + java
                                      + "','" + computer + "')");
                        System.out.println("n添加完成。");
                        break;

                 // 更改成绩
                 case 2:

                               System.out.println("请输入要改的学生学号:");
                               cid = Keyboard.getString();
                               System.out.println("数学:");
                               math = Keyboard.getInteger();
                               System.out.println("英语:");
                               english = Keyboard.getInteger();
                               System.out.println("JAVA:");
                               java = Keyboard.getInteger();
                               System.out.println("计算机:");
                               computer = Keyboard.getInteger();
                               stmt.executeUpdate("update lxh1 set math='" + math + "',english='"
                                             + english + "',java='" + java + "',computer='" + computer
                                             + "' where sno=" + cid + "");
                               System.out.println("n修改完成");
                               break;

                 // 删除指定学生
                 case 3:
                        System.out.println("请输入要改的学生学号:");
                        cid = Keyboard.getString();
                        stmt.executeUpdate("delete from lxh1 where sno=" + cid + "");
                        System.out.println("n删除完成");
                        break;

                 // 显示指定学生
                 case 4:
                        System.out.println("请输入查找的学生学号:");
                        cid = Keyboard.getString();
                        System.out.println("n" + cid
                                      + "号学生信息nn学号t姓名t数学t英语tJAVAt计算机t");
                        rs = stmt.executeQuery("select * from lxh1 where sno=" + cid
                                      + "");
                        while (rs.next())
                        {
                               System.out.println(rs.getInt("sno") + "t"
                                             + rs.getString("sname") + "t" + rs.getString("math")
                                             + "t" + rs.getString("english") + "t"
                                             + rs.getString("java") + "t"
                                             + rs.getString("computer") + "t");
                        }

                        break;

                 case 5:
                        // 输出全部信息
                        System.out.println("n全部学生信息nn学号t姓名t数学t英语tJAVAt计算机t平均成绩");
                        rs = stmt.executeQuery("select * from lxh1 order by math desc");
                        while (rs.next())
                        {
                               int a = rs.getInt("math");
                               int b = rs.getInt("english");
                               int c = rs.getInt("java");
                               int d = rs.getInt("computer");
                               System.out.println(rs.getString("sno") + "t"
                                             + rs.getString("sname") + "t" + a + "t" + b + "t"
                                             + c + "t" + d + "t" + ((a + b + c + d) / 4));
                        }
                        ;

                        // 输出平均分
                        System.out.println("n各科平均分nn数学t英语tJAVAt计算机t");
                        rs = stmt
                                      .executeQuery("select avg(math),avg(english),avg(java),avg(computer) from lxh1");
                        while (rs.next())
                        {
                               System.out.println(rs.getInt(1) + "t" + rs.getInt(2) + "t"
                                             + rs.getInt(3) + "t" + rs.getInt(4));
                        }
                        ;

                        // 输出最高分
                        System.out.println("n各科最高分nn数学t英语tJAVAt计算机t");
                        rs = stmt.executeQuery("select max(math),max(english),max(java),max(computer) from lxh1");
                        while (rs.next())
                        {
                               System.out.println(rs.getInt(1) + "t" + rs.getInt(2) + "t"
                                             + rs.getInt(3) + "t" + rs.getInt(4));
                        }
                        ;

                        // 输出最低分
                        System.out.println("n各科最低分nn数学t英语tJAVAt计算机t");
                        rs = stmt
                                      .executeQuery("select min(math),min(english),min(java),min(computer) from lxh1");
                        while (rs.next())
                        {
                               System.out.println(rs.getInt(1) + "t" + rs.getInt(2) + "t"
                                             + rs.getInt(3) + "t" + rs.getInt(4));
                        }
                        ;
                        break;

                 case 0:
                        break;

                 default:
                        System.out.println("感谢您的使用,再见!");
          }
          ;
          stmt.close();
          con.close();
   }

}

解决方案

需要导入java.io

import java.io.*;

http://www.cnblogs.com/xuxm2007/archive/2011/10/20/2219104.html

解决方案二:

应该是引入的Jar包不全引起的

时间: 2024-12-30 08:41:34

java-哪位大神帮忙解决一下Keyboard cannot be resolved的问题的相关文章

app-哪位大神帮忙解决一下 急急急

问题描述 哪位大神帮忙解决一下 急急急 点击app的图标进步去报如下的错误 java.lang.RuntimeException: Unable to instantiate application com.besttone.hall.MyApplication: java.lang.ClassNotFoundException: Didn't find class "com.besttone.hall.MyApplication"

请哪位大神帮忙解决下这个问题-内存泄露

问题描述 请哪位大神帮忙解决下这个问题-内存泄露 请哪位大神帮忙解决下这个问题,实在是找不到哪个地方内存泄露,凡是代码中用到new的,我都delete了... Detected memory leaks! Dumping objects -> {107} normal block at 0x00206188, 21 bytes long. Data: < l| > A8 6C 7C 00 04 00 00 00 04 00 00 00 01 00 00 00 {106} normal b

哪位大神帮忙解决下TFS建项目报错

问题描述 前几准备再建个项目,发现报错,上网找了好久都没有找到解决的办法以前也出现个这个报错,但是忘记是怎么解决的错误TF30170:插件Microsoft.ProjectCreationWizard.TestManagement在来自组TestManagement的任务TestVariable的执行期间出现失败.解释插件错误文本:"System.MissingFieldException:Fieldnotfound:'Microsoft.TeamFoundation.TestManagemen

spring mvc-maven+springmvc 报错,找了一下午没解决。哪位大神帮忙看看。

问题描述 maven+springmvc 报错,找了一下午没解决.哪位大神帮忙看看. SEVERE: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener at org.ap

跪求大神帮忙解决一个java问题

问题描述 跪求大神帮忙解决一个java问题 Invalid classpath publish/export dependency com.genuitec.runtime.library/com.genuitec.generic_6.0. The associated classpath container cannot be included in the published/exported module. 这个问题到底是啥意思,困扰一天了 解决方案 解决: 不要动eclipse.在控制台

跪求大神帮忙解决一个java语法问题

问题描述 跪求大神帮忙解决一个java语法问题 有行代码编译总是不能通过,我觉得是语法问题,但是找了很久都找不出来啊.请大婶帮忙解决,感激不尽. 解决方案 你的代码呢?你的代码呢? 解决方案二: 1.请把您的问题要点尽量在标题说明,大神都很忙,有时不会点进来看内容,会先用标题过滤一下:2.就算大神今天闲下来,您这也没代码可看啊. 解决方案三: 检查 1. 单词 有没有写错,2.命名是否不符合要求3.语法问题 需要看代码 解决方案四: 编译不通过的问题大致分为两种,1,语法错误.2.ide(ecl

求大神帮忙解决 Android项目java空指针异常问题 真的很急 - -

问题描述 求大神帮忙解决 Android项目java空指针异常问题 真的很急 - - 新手小白参考网上教程学习的socket使用,代码几乎雷同老师写的就可以运行我的就会出问题,connect()方法正确可用,但是send()方法不能用,会提示如图空指针异常,但是我真的找不到是哪里的问题,求大神指点.困扰两天了 茶不思饭不想.(由于提问字数问题导包部分代码没有粘过来) 我用Broadcast在一个activity中监听到操作后广播消息过来然后触发java类里面的方法,触发到connect()就可以

java代码-请教各位大神,遍历数据库 为什么只有一条数据,里面明明有两条数据,哪位大神帮忙看看

问题描述 请教各位大神,遍历数据库 为什么只有一条数据,里面明明有两条数据,哪位大神帮忙看看 <% Connection con; Statement stmt; ResultSet rs; Class.forName("com.mysql.jdbc.Driver"); DriverManager.registerDriver(new com.mysql.jdbc.Driver()); String DbConn = "jdbc:mysql://localhost/te

java 执行 sql 文件报错 求大神帮忙解决 急急急!!!!

问题描述 java 执行 sql 文件报错 求大神帮忙解决 急急急!!!! sql文件里边的内容 /* Navicat MySQL Data Transfer Source Server : localhost_3306 Source Server Version : 50096 Source Host : localhost:3306 Source Database : cemscenter1 Target Server Type : MYSQL Target Server Version :