java初学作业代码 作业帮java开发

java练习题求完整代码

按照题目要求编写的用javaBean规范设计的学生类Student的Java程序如下

创新互联主要从事成都做网站、网站设计、网页设计、企业做网站、公司建网站等业务。立足成都服务武宁,十余年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:028-86922220

需要创建user.java.test包,把Student.java文件和Test.java文件放入包中,编译Student.java文件并且编译运行Test.java文件得到运行结果

Student.java文件代码如下

package user.java.test;

import java.io.Serializable;

public class Student implements Serializable{

private static final long serialVersionUID = 1L;

private String no;

private String name;

private double score;

public Student(){}

public Student(String no,String name,double score){

this.no=no;

this.name=name;

this.score=score;

}

public String getNo(){ return no;}

public void setNo(String no){ this.no=no;}

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 String toString(){

return "学号:"+no+",姓名:"+name+",成绩:"+score;

}

public static double getAvg(Student[] sArray){

double sum=0,avg;

for(int i=0;isArray.length;i++){

sum=sum+sArray[i].getScore();

}

avg=sum/sArray.length;

return avg;

}

}

Test.java文件代码如下

package user.java.test;

public class Test{

public static void main(String[] args){

Student[] sArray=new Student[5];

sArray[0]=new Student("001","张三",89.5);

sArray[1]=new Student("002","李四",82.5);

sArray[2]=new Student("003","王五",93);

sArray[3]=new Student("004","赵六",73.5);

sArray[4]=new Student("005","孙七",66);

System.out.println("这些学生的平均分:"+Student.getAvg(sArray));

for(int i=0;isArray.length;i++){

System.out.println(sArray[i].toString());

}

}

}

java作业,求代码,谢谢!

代码如下:

package com.sxl.gd.test;

public class Array {

private int []a = {1,2,3,4,5,6};

private int x1,x2,x3,x4,x5,x6;

private void aver() {

int sum = 0;

for(int i=0;ia.length;i++) {

sum+=a[i];

}

System.out.println("平均数是:"+(double)sum/(double)a.length);

}

public Array() {}

public Array(int x1,int x2,int x3,int x4,int x5,int x6) {

a[0] = x1;

a[1] = x2;

a[2] = x3;

a[3] = x4;

a[4] = x5;

a[5] = x6;

}

private void min() {

int min = a[0];

for(int i=1;ia.length;i++) {

if(a[i]min) {

int temp;

temp = a[i];

a[i]=min;

min = temp;

}

}

System.out.println("最小值是:"+min);

}

private void max() {

int max = a[0];

for(int i=1;ia.length;i++) {

if(a[i]max) {

int temp;

temp = a[i];

a[i]=max;

max = temp;

}

}

System.out.println("最大值是:"+max);

}

public static void main(String[] args) {

Array array1 = new Array();

array1.aver();

array1.max();

array1.min();

Array array2 = new Array(6,2,8,4,1,7);

array2.aver();

array2.max();

array2.min();

}

}

运行结果如下:

Java的作业,新手不会做,求代码

class Person{

string name;

int age;

string address;

public String toString(){

return "姓名:"+name+" 家庭住址:"+address+" 年龄:"+age;

}

public Person(string name,int age,string address){

this.name = name;

this.age = age;

this.address = address;

}

}

class Employee extends Person{

int num;

public Employee(string a,int b,string c,int n){

name = a;

age = b;

address = c;

num = n;

}

}

class Student extends Person{

public Student(string a,int b,string c){

name = a;

age = b;

address = c;

}

}

public class

刚入门的java作业

代码

或者:

package com.xinhua.test2;

public class Student {

int sno;

String name;

double chiness;

double math;

double english;

double three_sco;

double all_s;

public Student(int sno, String name, double chiness, double math, double english, double three_sco) {

this.sno = sno;

this.name = name;

this.chiness = chiness;

this.math = math;

this.english = english;

this.three_sco = three_sco;

}

@Override

public String toString() {

return "学号:" + sno + ", 名字:" + name + ", 语文成绩:" + chiness + ", 数学成绩:" + math + ", 英语成绩:"

+ english + "总成绩:"+(chiness+math+english+three_sco);

}

public static void main(String[] args) {

Student A=new Student(1, "张三", 118, 145, 114.5, 198);

Student B=new Student(2, "李四", 130,110.5,100,210);

Student C=new Student(3, "王五",142.5,120,87.5,245.5);

System.out.println("学生列表信息为:");

System.out.println(A.toString());

System.out.println(B.toString());

System.out.println(C.toString());

//

double a_scoAll=A.chiness+A.math+A.english+A.three_sco;

A.all_s=a_scoAll;

double b_scoAll=B.chiness+B.math+B.english+B.three_sco;

B.all_s=b_scoAll;

double c_sclAll=C.chiness+C.math+C.english+C.three_sco;

C.all_s=c_sclAll;

Student[] s_s={A,B,C};

System.out.println("按总成绩从大到小排序为");

Student temp;

for(int i=0;is_s.length;i++){

for(int j=1;js_s.length-i;j++){

if(s_s[j-1].all_s s_s[j].all_s){

temp=s_s[j-1] ;

s_s[j-1] =s_s[j];

s_s[j]=temp;

}

}

}

for(int i=0;is_s.length;i++){

System.out.println("第"+(i+1)+"名为:"+s_s[i].toString());

}

}

}

望采纳

给段最简单的java代码 让我新手看一下

最简单的java代码肯定就是这个了,如下:

public class MyFirstApp

{

public static void main(String[] args)

{

System.out.print("Hello world");

}

}

“hello world”就是应该是所有学java的新手看的第一个代码了。如果是零基础的新手朋友们可以来我们的java实验班试听,有免费的试听课程帮助学习java必备基础知识,有助教老师为零基础的人提供个人学习方案,学习完成后有考评团进行专业测试,帮助测评学员是否适合继续学习java,15天内免费帮助来报名体验实验班的新手快速入门java,更好的学习java!


分享题目:java初学作业代码 作业帮java开发
路径分享:http://azwzsj.com/article/dooghhc.html