jave初学,求得下面编程题全部答案,希望能够尽量详细完整能运行 ,最好有注释,谢谢了!!?

如题所述

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;


public class demo {
public static void main(String[] args) {
//Y2Q();
//getStudentsMaxMark();
//get5Or6();
//get5Or6Two();
getPAndL();
}
/**
 * 第一题
 */
public static void Y2Q(){
System.out.println("英里                         千米");
for (int i = 1; i < 11; i++) {
System.out.println(i+"          "+i*1.609);
}
}

/**
 * 第二题
 */
public static void getStudentsMaxMark(){
System.out.println("输入学生人数!!");
Scanner s = new Scanner(System.in);
int nextInt = s.nextInt();
List<Student> arrayList = new ArrayList<Student>();

for (int i = 0; i < nextInt; i++) {
Student student = new Student();
System.out.println("输入姓名!!");
String name = s.next();
student.setName(name);
System.out.println("输入成绩!!");
int mark = s.nextInt();
student.setMark(mark);
arrayList.add(student);
}

Collections.sort(arrayList, new Comparator<Student>() {
@Override
public int compare(Student o1, Student o2) {
if(o1.getMark() > o2.getMark()) return -1;
else if(o1.getMark() == o2.getMark()) return 0;
else  return 1;
}
});
System.out.println("最高分"+arrayList.get(0).getName()+":"+arrayList.get(0).getMark());
s.close();
}

/**
 * 第三题
 */
public static void get5Or6(){
List<Integer> al = new ArrayList<Integer>();
for (int i = 100; i <= 1000; i++) {
if(i%5==0 || i%6==0){
al.add(i);
}
}

for (int i = 0; i < al.size(); i++) {
if(i%10==0){
System.out.println();
}
System.out.print(al.get(i)+" ");
}
}

/**
 * 第四题
 */
public static void get5Or6Two(){
List<Integer> al = new ArrayList<Integer>();
for (int i = 100; i <= 1000; i++) {
if(i%5==0 || i%6==0){
if(!(i%5==0 && i%6==0))al.add(i);
}
}

for (int i = 0; i < al.size(); i++) {
if(i%10==0){
System.out.println();
}
System.out.print(al.get(i)+" ");
}
}

/**
 * 第五题
 */

public static void getPAndL(){
System.out.println("整数    平分    立方");
for (int i = 0; i <= 10; i++) {
System.out.println(i+"    "+i*i+"    "+i*i*i);
}
}
}

class Student{
private String name;
private int mark;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getMark() {
return mark;
}
public void setMark(int mark) {
this.mark = mark;
}

}

追问

谢谢

温馨提示:答案为网友推荐,仅供参考
第1个回答  2016-04-14

  public static void main(String[] args) {

      public class xxxx{

      double a = 1.609;

      for(int i=0,i<10;i++){

      System.out.println(i + "\t" + i*a);

      }

      }

      }

  


本回答被网友采纳
第2个回答  2016-04-13
急么?明天中午可以给你追问

好的