import java.util.ArrayList
import java.util.List
import javax.swing.JOptionPane
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 List<Course>courseInfo
private String gpa
public String getName() {
return this.name
}
public void setName(String name) {
this.name = name
}
public List<Course>getCourseInfo() {
return this.courseInfo
}
public void setCourseInfo(List<Course>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"
// List<GPAInfo>gpaInfolist = new ArrayList<GPAInfo>()
// while((hasNextStudent != null) &&"y".equals(hasNextStudent.toLowerCase())) {
GPAInfo gpaInfo = new GPAInfo()
String name = JOptionPane.showInputDialog("enter a name")
gpaInfo.setName(name)
List<Course>courselist = new ArrayList<Course>()
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"
// List<Course>courselist = gpaInfo.getCourseInfo()
for (Course course : courselist) {
output += course.getCourse() + " " + course.getUnit() + " " + course.getScore() + "\n"
}
output += "平均点数GPA " + gpaInfo.getGpa() + "\n\n"
// }
System.out.println(output)
JOptionPane.showMessageDialog(null, output)
System.exit(-1)
}
private static String getGpa(List<Course>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.util.Calendar类,可以做个
万年历
的课表,不过要界面就要配合swing,但是你要在手机上运行就不能使用
j2se
,要用
j2me
.不过个人建议不要用java,java在手机上要用
java虚拟机
才可以运行,效率慢,所以建议使用C++
嵌入式编程
请帮我用JAVA数组的方式编写一个课程表,感激不尽!
public class IdUtil {
public static void main(String[] args) {
//七天的课程
String[] week = new String[7]
//每天的课程名
week[0] = "语文,语文,语文,语文,语文,语文,语文,语文,语文,语文"
week[1] = "数学,数学,数学,数学,数学,数学,数学,数学,数学,数学"
week[2] = "外语,外语,外语,外语,外语,外语,外语,外语,外语,外语"
week[3] = "物理,物理,物理,物理,物理,物理,物理,寂寞学,物理,物理"
week[4] = "化学,化学,化学,化学,化学,化学,化学,化学,化学,化学"
week[5] = "生物,生物,生物,生物,生物,生物,生物,生物,生物,生物"
week[6] = "寂寞学,寂寞学,寂寞学,寂寞学,寂寞学,寂寞学,寂寞学,寂寞学,寂寞学,寂寞学"
//上课时间
String[] time = {"8:00","9:00","8:00","8:00","8:00","8:00","8:00","8:00","8:00","8:00"}
for(int a=1a<8a++){
System.out.print("\t"+"星期"+a)
}
System.out.println()
int b = 0
for(int i=1i<11i++){
switch (i) {
case 1:
System.out.println("上午")
break
case 5:
System.out.println("下午")
break
case 9:
System.out.println("晚上")
break
}
System.out.print(time[i-1]+"\t")
for(int j=0j<7j++){
System.out.print(week[j].split(",")[b]+"\t")
}
System.out.println()
b++
}
}
}
用JAVA编写课程表cource 包含: 3个成员变量:课程编写(cnumber)、课程名(name)和学分(cunit)
要实现的什么说具体点
class cource{
int cnumber
String name
float cunit
}
java学习有没有课程表
课程表没有,这是朋友在叩丁狼学习的课程大纲,可以给你看看参考一下
第一阶段Java基础阶段
第二阶段、JavaWeb阶段
第三阶段、Web前端阶段
第四阶段、高级框架和技术阶段
第五阶段、互联网高薪技术阶段
第六阶段、七大实战项目(项目部分)阶段
用java实现课程表
你只需要一个选课表,存学生ID,课程ID,所有学生的选课都是这一个表,每次选课加一条数据,展现的时候根据用户去查选课表就行了
用Java做一个课程表
创建2个对象 *** ,判断差异,如果存在差异就将那条数据保存为文件内容
基本就这么简单
用java编写课程表
可以用GUI画个8X7的宫格
用Java怎样实现课表代码有周次
课表数据时存储于数据库中的吗?
/**
* 获取一周的时间 *** (从周一到周日)
* @param weekNum -1:上周;0:本周;1:下周
*/
public static List<Date>getWeekDates(int weekNum){
List<Date>list = new ArrayList<Date>()
Calendar cal = Calendar.getInstance()
// 获取指定下几个星期
cal.add(Calendar.DAY_OF_WEEK, weekNum * 7)
cal.setFirstDayOfWeek(Calendar.MONDAY)
cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY)
list.add(cal.getTime())
for(int i = 0i <6i++){
cal.add(Calendar.DAY_OF_WEEK, 1)
list.add(cal.getTime())
}
return list
}
这个是获取这一周时间的代码 ,之后用下面的代码获取周一到周日的日期
List<Date>ds = DateUtil.getNowWeekDates(weekNum)
ds.get(0)//周一
ds.get(6)//周日
用这两个时间到数据库中进行范围查询,之后的你应该明白了吧
//2020年3月12日编写
#include<stdio.h>
char c=' '
void chang()//长函数
{
printf("___________")
}
void kuang()//宽函数
{
printf("|")
}
void zon(char cc)//总汇函数
{
int a
printf("\n")
printf("|")
for(a=0a<4a++)
{
chang()
if(a<3)
printf("%c",cc)
}
printf("|")
}
void zon2(char a1[],char a2[],char a3[],char a4[])//总汇函数2
{
printf("\n")
printf("|%-11s|",a1)printf("%-11s|",a2)printf("%-11s|",a3)printf("%-11s|",a4)
}//函数;
main()
{
int a,b
for(a=0a<4a++)//第一行
{
printf(" ")
chang()
}
printf("\n|%21c课程表%20c|",c,c)
zon(' ')
zon2(" ","1.2节","3.4节","5.6节")
zon('|')
zon2("星期一","语文","计算机","体育")//第二行
zon('|')
zon2("星期二","数学","政治","数学")//第三行
zon('|')
zon2("星期三","英语","体育","自习")//第四行
zon('|')
zon2("星期四","计算机","语文","体育")//第五行
zon('|')
zon2("星期五","计算机","英语","自习")//第六行
zon('|')
}
/*
printf(" ___________\n")// -=11
printf("| 语 文 |\n")// |%2d字%3d字%2d|
printf("|___________|\n")// |%11d|
*/
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)