java打印成绩表代码 java打印报表
java输出学生学号,姓名,成绩
public class Student {
创新互联公司长期为数千家客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为清苑企业提供专业的网站制作、网站建设,清苑网站改版等技术服务。拥有10多年丰富建站经验和众多成功案例,为您定制开发。
private int kemu1, kemu2, kemu3, kemu4, kemu5;
public int getKemu1() {
return kemu1;
}
public void setKemu1(int kemu1) {
this.kemu1 = kemu1;
}
public int getKemu2() {
return kemu2;
}
public void setKemu2(int kemu2) {
this.kemu2 = kemu2;
}
public int getKemu3() {
return kemu3;
}
public void setKemu3(int kemu3) {
this.kemu3 = kemu3;
}
public int getKemu4() {
return kemu4;
}
public void setKemu4(int kemu4) {
this.kemu4 = kemu4;
}
public int getKemu5() {
return kemu5;
}
public void setKemu5(int kemu5) {
this.kemu5 = kemu5;
}
}
上边的是Student类
import java.util.ArrayList;
import java.util.Random;
public class Test {
public static void main(String[] args) {
ArrayListStudent list = new ArrayListStudent();
// 初始化成绩
for (int n = 0; n 20; n++) {
Student st = new Student();
st.setKemu1(new Random().nextInt(100));
st.setKemu2(new Random().nextInt(100));
st.setKemu3(new Random().nextInt(100));
st.setKemu4(new Random().nextInt(100));
st.setKemu5(new Random().nextInt(100));
list.add(st);
}
// 计算平均成绩
int avg = 0;
for (int n = 0; n 20; n++) {
avg += list.get(n).getKemu1();
avg += list.get(n).getKemu2();
avg += list.get(n).getKemu3();
avg += list.get(n).getKemu4();
avg += list.get(n).getKemu5();
}
double avg2 = avg / 20;
System.out.println("全班平均成绩" + avg2);
// 计算谁得奖
for (int n = 0; n 20; n++) {
double avg3;
int avg4 = 0;
avg4 += list.get(n).getKemu1();
avg4 += list.get(n).getKemu2();
avg4 += list.get(n).getKemu3();
avg4 += list.get(n).getKemu4();
avg4 += list.get(n).getKemu5();
avg3 = avg4;
System.out.println((n + 1) + "成绩为" + avg3);
if (avg3 (avg2 * 1.2)) {
System.out.println((n + 1) + "该生获得1等将");
}
if (avg3 (avg2 * 1.1)) {
System.out.println((n + 1) + "该生获得2等将");
}
}
}
}
好了 可以了
ArrayList是动态数组
求JAVA源代码
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class GradeStatistic {
public static void main(String[] args) {
GradeStatistic gs = new GradeStatistic();
ListMark list = new ArrayListMark();
float sum = 0;
while(true){
Scanner sc = new Scanner(System.in);
System.out.print("Please input student name: ");
String name = sc.nextLine();
if(name.equals("end")){
break;
}
System.out.print("Please input student score: ");
float score = sc.nextFloat();
sum += score;
list.add(gs.new Mark(name, score));
}
float max = list.get(0).getScore();
float min = list.get(0).getScore();
for(Mark mark: list){
if(max mark.getScore()){
max = mark.getScore();
}
if(min mark.getScore()){
min = mark.getScore();
}
}
float average = sum / list.size();
System.out.println("Average is: " + average);
System.out.println("Max is: " + max);
System.out.println("Min is: " + min);
}
private class Mark{
private String name;
private float score;
public Mark(String name, float score){
this.name = name;
this.score = score;
}
public String getName() {
return name;
}
public float getScore() {
return score;
}
}
}
----------------------
Please input student name: Zhang san
Please input student score: 100
Please input student name: Li Si
Please input student score: 91
Please input student name: Ec
Please input student score: 35
Please input student name: ma qi
Please input student score: 67
Please input student name: end
Average is: 73.25
Max is: 100.0
Min is: 35.0
编写一个JAVA程序,有命令行参数给出百分制成绩
if (course = 90) {
System.out.println("A");
} else if (course = 80 course 90) {
System.out.println("B");
} else if (course = 70 course 80) {
System.out.println("C");
} else if (course = 60 course 70) {
System.out.println("D");
} else {
System.out.println("E");
}
能帮我用java写个学生成绩表吗急用
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Student {
/**
* 学生成绩表
*/
private String name;//学生姓名
private double score;//学生成绩
public Student(){}
public Student(String name,double score){
this.name=name;
this.score=score;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getScore() {
return score;
}
public void setScore(double score) {
this.score = score;
}
//主函数
public static void main(String[] args) {
ListStudent list=new ArrayListStudent();
Student[] stu=new Student[5];
//为学生对象赋值
for(int i=0;i5;i++){
stu[i]=new Student();
Scanner sc=new Scanner(System.in);
System.out.print("请输入学生姓名:");
stu[i].setName(sc.next());
System.out.print("请输入学生成绩:");
stu[i].setScore(sc.nextDouble());
list.add(stu[i]);
}
//打印输出学生成绩表
System.out.println("姓名\t成绩");
for(Student s:list){
System.out.println(s.getName()+"\t"+s.getScore());
}
}
}
网站栏目:java打印成绩表代码 java打印报表
浏览路径:http://scjbc.cn/article/hjcihd.html