package sleest;
创新互联服务项目包括金沙网站建设、金沙网站制作、金沙网页制作以及金沙网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,金沙网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到金沙省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!
import java.util.Vector;
public class JavaMain {
世指 static private final int ARRAY_SIZE = 6;
public static void main(String[] args) {
VectorInteger theVector = new VectorInteger();
兆返判for (int cEachItem = 0; cEachItem ARRAY_SIZE; cEachItem++) {
theVector.add(cEachItem);
}
showVector(theVector);
theVector.removeElementAt(3);
showVector(theVector);
}
public static void showVector(VectorInteger theVector) {
if (theVector.isEmpty()) {
System.out.println("theVector is empty.");
return;
}
族改 for (int loop = 0; loop theVector.size(); loop++) {
System.out.print(theVector.get(loop));
System.out.print(", ");
}
System.out.println();
}
}
0, 1, 2, 3, 4, 5,
0, 1, 2, 4, 5,
你可以直接用Eclipse或者NetBeans的图形界面,之后添加组件的响搭芦应袭拍就可以啦,很方便的。。。拍枝羡。
创建一个名字为“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;
}
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;
}
}
代码如下,希望能让帆给你思路:
public class test {
public static void main(String[] args){
int score[]=new int[30];
int sum=0;
for(int i=0;iscore.length;i++)
{
//存储随机坦州雹的分数到score数组中
score[i]=(int) (Math.random()*99+1);
//同事将分数加给sum
sum+=score[i];
}
System.out.println("班级平均迹誉分:"+sum*1.0/30);
}
}