重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

java里录取信息的代码 java录入数据

Java编程题 查询高考录取分数线?

import java.util.Scanner;

化隆网站建设公司创新互联公司,化隆网站设计制作,有大型网站制作公司丰富经验。已为化隆数千家提供企业网站建设服务。企业网站搭建\外贸网站建设要多少钱,请找那个售后服务好的化隆做网站的公司定做!

public class App

{

public static void main(String[] args)

{

final String[][] strstrs=

{

{"民办本科","350 分"},{"艺术类本科","290 分"},

{"体育类本科","280 分"},{"二本","445 分"},

{"一本","555 分"}

};

final String msg="请输入要查询的录取分数线(比如民办本科、"+

"艺术类本科、体育类本科、二本、一本):";

String input;

boolean invalidate=true;

Scanner sc=new Scanner(System.in);

System.out.print(msg);

input=sc.nextLine().trim();

for(String[] strs : strstrs)

{

if(strs[0].equals(input))

{

System.out.printf("%s录取分数线:%s%n",input,strs[1]);

invalidate=false;

break;

}

}

if(invalidate)

System.out.println("没有相关查询的录取分数线");

sc.close();

}

}

用java编写一个数据库程序,我在编辑录入学生成绩时,可以录取,但是出现异常:Invalid handle这个问题

可能是因为你第一录入成功后你就把连接给关闭了所造成的吧!

java 录取学生

public class School {

private String name;

private double line;

public School(){};

public School(String name,double line) {

super();

this.name=name;

this.line = line;

}

public double getLine() {

return line;

}

public void setLine(double line) {

this.line = line;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

}

public class Student {

private String id;

private String name;

private double total;

private double sports;

public Student(){

}

public Student(String id, String name, double total, double sports) {

super();

this.id = id;

this.name = name;

this.total = total;

this.sports = sports;

}

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 double getTotal() {

return total;

}

public void setTotal(double total) {

this.total = total;

}

public double getSports() {

return sports;

}

public void setSports(double sports) {

this.sports = sports;

}

}

public class Pass {

public void status(School s,Student stu){

if(stu.getTotal()=s.getLine()||(stu.getSports()=96||stu.getTotal()=300)){

System.out.println("学号为:"+stu.getId()+" "+"姓名为:"+stu.getName()+"的同学被"+s.getName()+"录取,该学校的录取分数线为:"+s.getLine());

}else{

System.out.println("学号为:"+stu.getId()+" "+"姓名为:"+stu.getName()+"的同学没有被"+s.getName()+"录取,该学校的录取分数线为:"+s.getLine());

}

}

public static void main(String[] args){

School school1=new School("清华大学",680);

School school2=new School("北京大学",660);

Student stu1=new Student("2012121201","小红",690,80);

Student stu2=new Student("2012121201","小明",650,80);

Student stu3=new Student("2012121201","张三",670,80);

Student stu4=new Student("2012121201","李四",640,80);

Pass p=new Pass();

p.status(school1, stu1);

p.status(school1, stu2);

p.status(school2, stu3);

p.status(school2, stu4);

}

}

运行结果为:

学号为:2012121201 姓名为:小红的同学被清华大学录取,该学校的录取分数线为:680.0

学号为:2012121201 姓名为:小明的同学被清华大学录取,该学校的录取分数线为:680.0

学号为:2012121201 姓名为:张三的同学被北京大学录取,该学校的录取分数线为:660.0

学号为:2012121201 姓名为:李四的同学被北京大学录取,该学校的录取分数线为:660.0

java的问题

import java.util.ArrayList;

import java.util.List;

class School {

private double line;

public double getLine() {

return line;

}

public void setLine(double line) {

this.line = line;

}

}

class Student{

public Student() {

}

public Student(String name, String id, double total, double sports) {

this.name = name;

this.id = id;

this.total = total;

this.sports = sports;

}

private String name;

private String id;

private double total;

private double sports;

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public String getId() {

return id;

}

public void setId(String id) {

this.id = id;

}

public double getTotal() {

return total;

}

public void setTotal(double total) {

this.total = total;

}

public double getSports() {

return sports;

}

public void setSports(double sports) {

this.sports = sports;

}

@Override

public String toString() {

return "姓名:"+name+"编号:"+id+"综合成绩:"+total+"体育成绩:"+sports;

}

}

class Pass{

public boolean isPass(School school,Student student){

if (student.getTotal()=school.getLine()||(student.getSports()96student.getTotal()300)) {

return true;

}else {

return false;

}

}

}

public class Test {

public static void main(String[] args) {

Student student1=new Student("张三","001",400,95);

Student student2=new Student("李四","002",450,98);

Student student3=new Student("王五","003",200,98);

ListStudent students=new ArrayListStudent();

students.add(student1);

students.add(student2);

students.add(student3);

Pass pass=new Pass();

School school=new School();

school.setLine(399);

for (Student student : students) {

if (pass.isPass(school, student)) {

System.out.println("被录取"+student);

}

}

}

}


本文题目:java里录取信息的代码 java录入数据
URL标题:http://cqcxhl.com/article/ddgseoj.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP