急!!!JAVA编程求答案。十万火急!!!
package com.itek.test;
/*
* @autor Aaron Jone
* @datetime:2017年3月13日 下午1:17:36
*/
public class Student {
private int age; // 年龄
private String department; // 院部
private String major; // 专业
private String name; // 姓名
private int clazz; // 班级
private double oop; // 面向对象程序设计
private double net; //网络原理
private double db; //数据库
private double totalScore; //总分
/*
* 无参构造方法:
*/
public Student(){
}
/*
* 有参构造方法:
*/
public Student(int age, String department, String major, String name, int clazz, double oop, double net, double db) {
super();
this.age = age;
this.department = department;
this.major = major;
this.name = name;
this.clazz = clazz;
this.oop = oop;
this.net = net;
this.db = db;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
public String getMajor() {
return major;
}
public void setMajor(String major) {
this.major = major;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getClazz() {
return clazz;
}
public void setClazz(int clazz) {
this.clazz = clazz;
}
public double getOop() {
return oop;
}
public void setOop(double oop) {
this.oop = oop;
}
public double getNet() {
return net;
}
public void setNet(double net) {
this.net = net;
}
public double getDb() {
return db;
}
public void setDb(double db) {
this.db = db;
}
public double getTotalScore() {
return totalScore;
}
public void setTotalScore(double totalScore) {
this.totalScore = totalScore;
}
}
-------------------------------------------------------------------------------------
package com.itek.test;
import java.util.Scanner;
/*
* @autor Aaron Jone
* @datetime:2017年3月13日 下午1:23:45
*/
public class MyStudent {
public static void main(String[] args) {
//第一题:
Student student = new Student(); // 创建对象
student.setAge(22); //年龄设置为:22
student.setClazz(1); //班级设置为:1
student.setDb(67.5); //数据库分数设置为:67.5
student.setDepartment("计算机学院"); //院部设置为:计算机学院
student.setMajor("软件工程"); //专业设置为:软件工程
student.setName("张三"); //姓名设置为:张三
student.setNet(87.8); //网络原理分数设置为:87.8
student.setOop(97.0); //面向对象程序设计分数设置为:97.0
/*
* 计算总成绩存入totalScore变量中
*/
double totalScore = student.getDb()+student.getNet()+student.getOop();
student.setTotalScore(totalScore);//设置学生总分为:totalScore
/*
* 在控制台打印
*/
System.out.println("姓名:"+student.getName()+"\t学院:"+student.getDepartment()+"\t专业:"+student.getMajor()+"\t班级:"+student.getClazz()+"\t总分:"+student.getTotalScore());
//第二题:
Student stu1 = new Student(23, "计算机学院", "软件工程", "李四", 2, 67.5, 79, 96);
double totalScore2 = stu1.getDb()+stu1.getOop()+stu1.getNet();
stu1.setTotalScore(totalScore2);
System.out.println("姓名:"+stu1.getName()+"\t学院:"+stu1.getDepartment()+"\t专业:"+stu1.getMajor()+"\t班级:"+stu1.getClazz()+"\t总分:"+stu1.getTotalScore());
//第三题 顺序一定要是:age clazz db oop net name department major
Student stu2 = new Student();
stu2.setAge(Integer.parseInt(args[0]));
stu2.setClazz(Integer.parseInt(args[1]));
stu2.setDb(Double.parseDouble(args[2]));
stu2.setOop(Double.parseDouble(args[3]));
stu2.setNet(Double.parseDouble(args[4]));
stu2.setName(args[5]);
stu2.setDepartment((args[6]));
stu2.setMajor((args[7]));
//设置完了,计算总成绩并设置总成绩
double totalScore3 = stu2.getNet()+stu2.getOop()+stu2.getDb();
stu2.setTotalScore(totalScore3);
//输出打印
System.out.println("姓名:"+stu2.getName()+"\t学院:"+stu2.getDepartment()+"\t专业:"+stu2.getMajor()+"\t班级:"+stu2.getClazz()+"\t总分:"+stu2.getTotalScore());
//第四题
Student stu3 = new Student();
//设置年龄
System.out.println("请输入年龄:");
int age = Integer.parseInt(MyStudent.getInput());
stu3.setAge(age);
//设置班级
System.out.println("请输入班级:");
int clazz = Integer.parseInt(MyStudent.getInput());
stu3.setClazz(clazz);
//设置院部
System.out.println("请输入院部:");
String department = MyStudent.getInput();
stu3.setDepartment(department);
//设置专业
System.out.println("请输入专业:");
String major = MyStudent.getInput();
stu3.setMajor(major);
//设置姓名
System.out.println("请输入姓名:");
String name = MyStudent.getInput();
stu3.setName(name);
//设置数据库成绩
System.out.println("请输入数据库成绩:");
double db = Double.parseDouble(MyStudent.getInput());
stu3.setDb(db);
//设置面向对象程序设计成绩
System.out.println("请输入面向对象程序设计成绩:");
double oop = Double.parseDouble(MyStudent.getInput());
stu3.setOop(oop);
//设置网络原理成绩
System.out.println("请输入网络原理成绩:");
double net = Double.parseDouble(MyStudent.getInput());
stu3.setNet(net);
//设置完了,计算总成绩并设置总成绩
double totalScore4 = stu3.getNet()+stu3.getOop()+stu3.getDb();
stu3.setTotalScore(totalScore4);
//打印输出
System.out.println("姓名:"+stu3.getName()+"\t学院:"+stu3.getDepartment()+"\t专业:"+stu3.getMajor()+"\t班级:"+stu3.getClazz()+"\t总分:"+stu3.getTotalScore());
}
/*
* 静态方法:也叫类方法
* 调用方式:类名.方法名
* 功能:get控制台输入的 数据,返回字符串类型
*/
public static String getInput(){
Scanner sc = new Scanner(System.in);
return sc.nextLine();
}
}