java编制绩点代码 java成绩

用java编写一个绩点计算程序,输入科目,学分,成绩,求平均绩点,解决不了自主输入科目的问题,求解决!

数据库里面开一个字段,外面定义一个String变量,当你输入文字(科目)的适合,赋值给这个变量,之后用SQL语句插入到数据库的字段就可以了。

成都创新互联公司是一家集网站建设,寿阳企业网站建设,寿阳品牌网站建设,网站定制,寿阳网站建设报价,网络营销,网络优化,寿阳网站推广为一体的创新建站企业,帮助传统企业提升企业形象加强企业竞争力。可充分满足这一群体相比中小企业更为丰富、高端、多元的互联网需求。同时我们时刻保持专业、时尚、前沿,时刻以成就客户成长自我,坚持不断学习、思考、沉淀、净化自己,让我们为更多的企业打造出实用型网站。

用java写一个计算GPA成绩的程序

姓名和成绩我不知道你想怎样输入,只给出算GPA的算法,输入输出你自己来写吧,如果输入输出你不学的话,我也帮不了你。

//marks是一个学生成绩的数组,hours是该学生选课的学分的数组

private double getGPA(String[] marks, int[] hours)

{

double sumHour = 0;//总学分

double sumHourPoint = 0;//总学分绩点

for (int i = 0; i hours.length; i++)

{

sumHour += hours[i];

sumHourPoint += pointOf(marks[i]) * hours[i];

}

return sumHourPoint / sumHour;//GPA = 总学分绩点/总学分

}

private double pointOf(mark){//计算单科绩点

double point = 0;

switch(mark.charAt(0))

{

case 'A': point = 4;

case 'B': point = 3;

case 'C': point = 2;

case 'D': point = 1;

default: point = 0;

}

if(mark.length() 1)

{

switch(mark.charAt(1))

{

case '+': point += 0.5; break;

default: break;

}

}

return point;

}

求解这个JAVA程序怎么编?看不懂题意!

提供一些思路吧,编写一个Student类,其中有各种属性,比如名字:String name;

选修课程:String[] xuanxius;

平均成绩:double avg;

各科成绩:int[] chengjis;

平均成绩的get方法是:for循环各科成绩,进行相加,得到的总成绩再除以chengjis.length;得到的double值就是平均成绩

然后根据平均成绩进行判断,属于哪个段,就把对应的abcd输出就行了

输出就简单了吧,自己输出就行,要是有什么不明白可以追问

计算GPA和学分的java程序

import java.util.ArrayList;

import java.util.List;

import javax.swing.JOptionPane;

//名字;---

//课程名称#1;----

//总共学分:

//成绩:使用ABCDF计算格式;A=4分, B=3.。。

//有没有其他课程#2:Yes/no 名称---

//

//显示:

//

//名字:XXX

//课程 学分 成绩

//计算机课 4 B+

//数学 5 B

//平均点数GPA 3.0

class Course {

private String course;

private String unit;

private String grade;

private String score;

public String getCourse() {

return this.course;

}

public void setCourse(String course) {

this.course = course;

}

public String getUnit() {

return this.unit;

}

public void setUnit(String unit) {

this.unit = unit;

}

public String getGrade() {

return this.grade;

}

public void setGrade(String grade) {

this.grade = grade;

}

public String getScore() {

return this.score;

}

public void setScore(String score) {

this.score = score;

}

}

class GPAInfo {

private String name;

private ListCourse courseInfo;

private String gpa;

public String getName() {

return this.name;

}

public void setName(String name) {

this.name = name;

}

public ListCourse getCourseInfo() {

return this.courseInfo;

}

public void setCourseInfo(ListCourse courseInfo) {

this.courseInfo = courseInfo;

}

public String getGpa() {

return this.gpa;

}

public void setGpa(String gpa) {

this.gpa = gpa;

}

}

public class GPA {

public static void main(String[] args) {

String hasNextStudent = "y";

String hasNextCourse = "y";

ListGPAInfo gpaInfolist = new ArrayListGPAInfo();

while((hasNextStudent != null) "y".equals(hasNextStudent.toLowerCase())) {

GPAInfo gpaInfo = new GPAInfo();

String name = JOptionPane.showInputDialog("enter a name");

gpaInfo.setName(name);

ListCourse courselist = new ArrayListCourse();

while ((hasNextCourse != null) "y".equals(hasNextCourse.toLowerCase())) {

Course course = new Course();

String courseName = JOptionPane.showInputDialog(" What class do you have?");

course.setCourse(courseName);

String unit = JOptionPane.showInputDialog(" Enter the units you get");

course.setUnit(unit);

String grade = JOptionPane.showInputDialog(" Grade you get?");

course.setGrade(grade);

course.setScore(String.valueOf(getScore(grade.toCharArray()[0])));

courselist.add(course);

hasNextCourse = JOptionPane.showInputDialog(" other class? Yes or no");

}// while has next course

hasNextCourse = "y";

gpaInfo.setCourseInfo(courselist);

gpaInfo.setGpa(getGpa(courselist));

gpaInfolist.add(gpaInfo);

hasNextStudent = JOptionPane.showInputDialog(" other student? Yes or no");

}// while has next student

String output = "";

for (GPAInfo gpaInfo : gpaInfolist) {

output += "名字:" + gpaInfo.getName() + "\n";

output += "课程 学分 成绩" + "\n";

ListCourse courselist = gpaInfo.getCourseInfo();

for (Course course : courselist) {

output += course.getCourse() + " " + course.getUnit() + " " + course.getScore() + "\n";

}

output += "平均点数GPA " + gpaInfo.getGpa() + "\n\n";

}

JOptionPane.showMessageDialog(null, output);

System.exit(-1);

}

private static String getGpa(ListCourse courselist) {

double avg = 0;

int totalScore = 0;

int totalUnit = 0;

for (Course course : courselist) {

totalUnit += Integer.parseInt(course.getScore());

totalScore += Integer.parseInt(course.getUnit()) * Integer.parseInt(course.getScore());

}

if (totalUnit != 0) {

avg = totalScore / totalUnit;

}

if (avg 4) {

avg = 4;

}

return String.valueOf(avg);

}

private static int getScore(char score) {

int point;

score = Character.toUpperCase(score);

switch (score) {

case 'A':

point = 4;

break;

case 'B':

point = 3;

break;

case 'C':

point = 2;

break;

case 'D':

point = 1;

break;

default:

point = 0;

break;

}

return point;

}

}


当前题目:java编制绩点代码 java成绩
网页URL:http://scyanting.com/article/dohhhhs.html