Java语言编程,求代码!!

各位编程高手,帮忙写一下代码! 1、 编写程序,从键盘获取6个整数,从中找出最大的和最小的,并输出。2、编程实现:首先建包myPackage,在该包下定义一个Student类,该类包括学号、姓名、性别、出生年月等属性及init()-----初始化各属性(以自己的情况为例子)、display()--------显示各属性,modify(String name)——修改姓名等方法; 再建一个包test,在该包下定义一个Test类,要求利用Test类来测试Student的各个方法。3、 编写程序,通过键盘输入考试成绩的等级,打印出相应的百分制分数段,设A为90分以上, B为80分以上, C为70分以上, D为60分以上, E为59分以下。

1.

import java.util.Scanner;

public class Test {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub

Scanner scanner=new Scanner(System.in);

int a[]= new int[6];

for(int i=0;i<a.length;i++){
int m=scanner.nextInt();
a[i]=m;
}
int temp;
for(int i=0;i<a.length;i++){
for(int j=0;j<a.length-i-1;j++){
if(a[i]>a[i+1]){
temp=a[i];
a[i]=a[i+1];
a[i+1]=temp;
}
}
}

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

}
System.out.println("最大值是:"+a[a.length-1]+"\t"+"最小值是:"+a[0]);

}

}
2.
package mypackage;

import java.util.Scanner;

public class Student {

public int id;
public String name;
public String sex;

public void init(){

this.id=23;
this.name="wo";
this.sex="女";
}

public void display(){

System.out.println(id);
System.out.println(name);
System.out.println(sex);
}

public String modified(String name){

this.name=name;

return name;
}

}
test类
package test;

import mypackage.Student;

public class StuTest {
public static void main(String args[]){
Student t=new Student();

t.init();

t.display();

t.modified("ni");
}
}
3.
package test;

import java.util.Scanner;

public class Test {

public static void main(String args[]){

for(;;){
System.out.println("请输入考试成绩等级(A-Z 或者 a-z):如果想要退出请选择0");
Scanner scanner=new Scanner(System.in);
String str=scanner.next();

if(str.equals("0")){
break;
}
while(true){
if(str.length()>1){
System.out.println("输入的长度过长,请重新输入 !!!");
continue;
}
else if(str.length()==1){
char c=str.charAt(0);

int m=c;
if((m>=65 && m<=69)||(m>=97&&m<=101)){
if(str.equals("A")||str.equals("a")){
System.out.println(str+"所对应的分数段为:"+"90分以上");
break;
}
else if(str.equals("B")||str.equals("b")){
System.out.println(str+"所对应的分数段为:"+"80分以上");
break;
}
else if(str.equals("C")||str.equals("c")){
System.out.println(str+"所对应的分数段为:"+"70分以上");
break;
}
else if(str.equals("D")||str.equals("d")){
System.out.println(str+"所对应的分数段为:"+"60分以上");
break;
}
else if(str.equals("E")||str.equals("e")){
System.out.println(str+"所对应的分数段为:"+"59分以下");
break;
}
}
else {
System.out.println("输入的不在A-Z或者a-z之间");
break;
}

}

}

}
}

}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-01-11
第一个问题用数组和两个for循环 第二个问题太简单了 就是一个类 按照书上的那一章 成员变量 就是方法调用一下 记得变量和方法的 词 public,,,,System.out.println("姓名:"+name+"/n")后面的几个差不多 第三个 在开头先导入上面那个包 下面调用就行了本回答被网友采纳
第2个回答  2012-01-12
我可以教你 你给我采纳答案
第3个回答  2012-01-13
关注学习
相似回答