java代码题库 java题库系统源码

(java)题库中有20道题,随机抽10道不同的题出来 怎么写代码 在线等啊import java.util.*;
class Untitled {
public static void main(String[] args) throws Exception {
Integer[] questions = generateQuestions();
for(Integer question : questions) {
System.out.println(question);
}
}
private static Integer[] generateQuestions() {
ListInteger questionNumbers = new ArrayListInteger();
Random rand = new Random();
int questionNumber, i = 0;
while(i10) {
questionNumber = rand.nextInt(21);
if(!questionNumbers.contains(questionNumber)) {
questionNumbers.add(questionNumber);
i;
}
}
return questionNumbers.toArray(new Integer[10]);
}
}
这两道题代码怎么写java?创建一个名字为“ReportCard”的类 , 然后用下边的内容全部替换掉,你会成为全班最亮的仔 。
import java.util.HashMap;
/**
* 学生成绩单
*/
public class ReportCard {
public static void main(String[] args) {
ReportCard reportCard = new ReportCard("张三", "070602213");
reportCard.set("语文", 80.0);
reportCard.set("数学", 59.5);
reportCard.set("英语", 66.0);
reportCard.set("java", 80, 99.0);
reportCard.set("数据库", 80, 66.0);
reportCard.set("毛概", null);
System.out.println(reportCard.getStudentName()"语文分数:"reportCard.get("语文"));
System.out.println(reportCard.getStudentName()"数学考核结果:"(reportCard.isPassed("数学") ? "合格" : "不合格"));
System.out.println(reportCard.getStudentName()"期末是否挂科:"(reportCard.isAllPassed() ? "否" : "是"));
}
// 学生姓名
private String studentName;
// 学生学号
private String studentNumber;
// 成绩单
private HashMapString, CourseResult cards = new HashMap();
public ReportCard() {
}
public ReportCard(String studentName, String studentNumber) {
this.studentName = studentName;
this.studentNumber = studentNumber;
}
public Double get(String courseName){
CourseResult courseResult = cards.get(courseName);
return courseResult == null ? Double.NaN : courseResult.getStudentScore();
}
public void set(String courseName, Double studentScore){
CourseResult courseResult = new CourseResult(courseName, studentScore);
cards.put(courseName, courseResult);
}
public void set(String courseName, double passMark, Double studentScore){
CourseResult courseResult = new CourseResult(courseName, passMark, studentScore);
cards.put(courseName, courseResult);
}
public boolean isPassed(String courseName){
return cards.get(courseName).isPassed();
}
public boolean isAllPassed(){
for(CourseResult cr : cards.values()){
if ( ! cr.isPassed()) {
return false;
}
}
return true;
【java代码题库 java题库系统源码】}
public String getStudentName() {
return studentName;
}
public String getStudentNumber() {
return studentNumber;
}
public void setStudentName(String studentName) {
this.studentName = studentName;
}
public void setStudentNumber(String studentNumber) {
this.studentNumber = studentNumber;
}
/**
* 课程
*/
class Course{
// 课程名称
protected String courseName;
// 及格分
protected double passMark = 60;
public Course(String courseName, Double passMark) {
this.courseName = courseName;
if ( passMark != null) {
this.passMark = passMark;
}
}
}
/**
* 课程成绩
*/
class CourseResult extends Course{
// 学生成绩
private Double studentScore;
public CourseResult(String courseName, Double studentScore) {
this(courseName, null, studentScore);
}
public CourseResult(String courseName, Double passMark, Double studentScore) {
super(courseName, passMark);
this.studentScore = studentScore == null ? Double.NaN : studentScore;
}
public boolean isPassed(){
return studentScore = passMark;
}
public String getCourseName() {
return courseName;
}
public double getPassMark() {
return passMark;
}
public Double getStudentScore() {
return studentScore;
}
}
java编程题1.package test;
import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;
public class Test {
public static void main(String[] args) {
String str = "afdjasdg$$jfsjdfjdjjdjdjdjdjdj";
int max=0;
Object chars=null;
Map tree = new TreeMap();
for (int i = 0; istr.length(); i) {
char ch = str.charAt(i);
if ((ch = 1ch = 255) ) {
if (!tree.containsKey(ch)) {
tree.put(ch, new Integer(1));
} else {
Integer in = (Integer) tree.get(ch)1;
tree.put(ch, in);
}
}
}
Iterator tit = tree.keySet().iterator();
while (tit.hasNext()) {
Object temp = tit.next();
if(max=Integer.parseInt(tree.get(temp) ""))
{
max=Integer.parseInt(tree.get(temp) "");
chars=temp;
}
}
System.out.print(chars.toString()"出现"max"次");
}
}
只要用assic码做范围就可以了.任何字符都可以过滤.
2.方法很多,hashmap或是arraylist,数组都可以的.就是对应关系而已.
package test;
public class ListTest {
static String[] to_19 = { "zero", "one", "two", "three", "four", "five",
"six", "seven", "eight", "nine", "ten", "eleven", "twelve",
"thirteen", "fourteen", "fifteen", "sixteen", "seventeen",
"eighteen", "nineteen" };
static String[] tens = { "twenty", "thirty", "forty", "fifty", "sixty",
"seventy", "eighty", "ninety" };
static String[] denom = { "", "thousand ", "million", "billion",
"trillion", "quadrillion", "quintillion", "sextillion",
"septillion", "octillion", "nonillion", "decillion", "undecillion",
"duodecillion", "tredecillion", "quattuordecillion",
"sexdecillion", "septendecillion", "octodecillion",
"novemdecillion", "vigintillion" };
public static void main(String[] argv) throws Exception {
long tstValue = https://www.04ip.com/post/12345;
ListTest itoe = new ListTest();
System.out.println(itoe.english_number(tstValue));
}
private String convert_nn(int val) {
if (val20) return to_19[val];
int flag = val / 10 - 2; if (val % 10 != 0)
return tens[flag]"-"to_19[val % 10];
else return tens[flag];
}
private String convert_nnn(int val) {
String word = "";
int rem = val / 100;
int mod = val % 100;
if (rem0) {word = to_19[rem]" hundred ";}
if (mod0) {word = wordconvert_nn(mod);}
return word;
}
public String english_number(long val) {
if (val100) {System.out.println((int) val);return convert_nn((int) val);}
if (val1000) {return convert_nnn((int) val); }
for (int v = 0; vdenom.length; v) {
int didx = v - 1;
long dval = new Double(Math.pow(1000, v)).longValue();
if (dvalval) {
long mod = new Double(Math.pow(1000, didx)).longValue();
int l = (int) (val / mod);
long r = (long) (val - (l * mod));
String ret = convert_nnn(l)" "denom[didx];
if (r0) {ret = ret", "english_number(r);}
return ret;
}
}
return null;
}
}
java代码题库的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于java题库系统源码、java代码题库的信息别忘了在本站进行查找喔 。

    推荐阅读