java答题系统设计代码 java程序设计基础题库及答案
在用java做一个在线考试系统,随机抽题遇到了问题,我写了一个随机抽题的方法,不知道在asp按钮中怎么用
import java.util.Random;
创新互联建站为企业级客户提高一站式互联网+设计服务,主要包括成都网站制作、成都网站设计、app软件定制开发、重庆小程序开发公司、宣传片制作、LOGO设计等,帮助客户快速提升营销能力和企业形象,创新互联各部门都有经验丰富的经验,可以确保每一个作品的质量和创作周期,同时每年都有很多新员工加入,为我们带来大量新的创意。
import java.util.Scanner;
public class MaxNumber {
private static Scanner input = new Scanner(System.in); // 实例控制台输入类
public static void main(String[] args) {
/*
* 第一步, 按照题目要求 , 我们需要用户输入 10 个数字
*/
int[] numberArray = new int[10]; // 我们先定义一个 可以装 10 个数字的数组
int choose = chooseMode(); // 我加了一个选择模式的函数
if (choose == 1) { // 用户手工输入
for (int i = 0; i numberArray.length; i++) { // 循环输入
System.out.print("请定义第 '" + (i + 1) + "' 个数字:"); // 输出控制台提示
numberArray[i] = input.nextInt(); // 要求输入, 并存储到数组变量里
}
} else { // 计算机随机生成
Random random = new Random(); // 随机数类
int tempNumber = 0 ; // 临时变量
for (int i = 0; i numberArray.length; i++) { // 计算机生成
tempNumber = random.nextInt(100) + 1; // 随机生成 1 - 100 的数
System.out.println("计算机生成的第 '" + (i + 1) + "' 个数字是:" + tempNumber);
numberArray[i] = tempNumber; // 赋值
}
}
/*
* 第二步 , 找这 10 个数当中 , 最大的数.
*/
int maxNumber = 0; // 定义一个变量接收最大的数
for (int i = 0; i numberArray.length; i++) { // 循环寻找
/*
* 循环比对, 一个接一个的, 如果 '当前数' , 比我们已经记录的 '最大数' 还大, 那我们就把当前数 赋给 最大数
*/
if (numberArray[i] maxNumber) {
maxNumber = numberArray[i];
}
}
System.out.println("其中最大的数是:" + maxNumber); // 输出结果
}
/**
* 选择模式方法
* @return 返回选择的模式的编号
*/
public static int chooseMode() {
System.out.println("------------ 选择模式 ------------");
System.out.println("\t1. 用户输入十个数字");
System.out.println("\t2. 计算机随机产生十个数字");
System.out.print("请选择:");
return input.nextInt(); // 输入, 返回
}
/*
* 其中包函的知识有: 控制台输入, 输出 , 数组 , 循环 , if 判断语句
*/
}
最后:
希望能帮到你,如果有什么问题可以 Hi 我,
看到楼主花了怎么多耐心,写了怎么多判断,也可以见得楼主确实用心了,
只是没找到方法。
基于java设计一个学生成绩管理系统,要求有界面,且有增加,查询,修改,删除,退出功能,代码如何写?
import java.awt.Color;
import java.awt.Font;
import java.awt.Frame;
import java.awt.Label;
import java.awt.TextField;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.sql.SQLException;
import javax.swing.JButton;
public class Stmessege {
Font font = new Font("楷体", Font.BOLD, 18);
private Frame m = new Frame("登陆成功界面");
protected Window f;
public Stmessege() {
m.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent evt) {
m.setVisible(false);
m.dispose();
System.exit(0);
}
});
m.setSize(460, 360);
m.setBackground(Color.green);
m.setLayout(null);
m.setLocationRelativeTo(null);
Label l0 = new Label("管理员信息");
Font font1 = new Font("楷体", Font.BOLD, 32);
l0.setForeground(Color.blue);
l0.setSize(180, 50);
l0.setLocation(150, 30);
l0.setFont(font1);
final Label l1 = new Label("姓名:");
l1.setSize(60, 20);
l1.setLocation(10, 100);
l1.setFont(font);
TextField tf1 = new TextField("黄朋");
tf1.setForeground(Color.blue);
tf1.setBackground(Color.white);
tf1.setSize(50, 20);
tf1.setLocation(70, 100);
final Label l2 = new Label("学号:");
l2.setSize(60, 20);
l2.setLocation(140, 100);
l2.setFont(font);
TextField tf2 = new TextField("111265");
tf2.setForeground(Color.blue);
tf2.setBackground(Color.white);
tf2.setSize(60, 20);
tf2.setLocation(190, 100);
final Label l3 = new Label("性别:");
l3.setSize(60, 20);
l3.setLocation(280, 100);
l3.setFont(font);
TextField tf3 = new TextField("男");
tf3.setForeground(Color.blue);
tf3.setBackground(Color.white);
tf3.setSize(40, 20);
tf3.setLocation(360, 100);
final Label l4 = new Label("班级:");
l4.setSize(60, 20);
l4.setLocation(10, 170);
l4.setFont(font);
TextField tf4 = new TextField("611231");
tf4.setForeground(Color.blue);
tf4.setBackground(Color.white);
tf4.setSize(60, 20);
tf4.setLocation(67, 170);
final Label l5 = new Label("系别:");
l5.setSize(60, 20);
l5.setLocation(140, 170);
l5.setFont(font);
TextField tf5 = new TextField("计算机工程系");
tf5.setForeground(Color.blue);
tf5.setBackground(Color.white);
tf5.setSize(80, 20);
tf5.setLocation(200, 170);
final Label l6 = new Label("成绩:");
l6.setSize(60, 20);
l6.setLocation(280, 170);
l6.setFont(font);
TextField tf6 = new TextField("95");
tf6.setForeground(Color.blue);
tf6.setBackground(Color.white);
tf6.setSize(40, 20);
tf6.setLocation(360, 170);
final Label l7 = new Label("专业:");
l7.setSize(60, 20);
l7.setLocation(10, 230);
l7.setFont(font);
TextField tf7 = new TextField("软件技术");
tf7.setForeground(Color.blue);
tf7.setBackground(Color.white);
tf7.setSize(60, 20);
tf7.setLocation(70, 230);
JButton btn1 = new JButton("添加");
btn1.setForeground(Color.blue);
btn1.setSize(80, 38);
btn1.setLocation(35, 300);
btn1.setFont(font);
btn1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
new 插入();
m.setVisible(true);
}
});
JButton btn2 = new JButton("查询学生学籍信息");
btn2.setForeground(Color.blue);
btn2.setSize(200, 38);
btn2.setLocation(135, 300);
btn2.setFont(font);
btn2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Stmessege1 f;
try {
f = new Stmessege1();
f.Stmessege11();
m.setVisible(true);
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (ClassNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
});
JButton btn3 = new JButton("删除");
btn3.setForeground(Color.blue);
btn3.setSize(80, 38);
btn3.setLocation(350, 300);
btn3.setFont(font);
btn3.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
new 删除();
//f.setVisible(false);
m.setVisible(true);
}
});
JButton btn4 = new JButton("更新");
btn4.setForeground(Color.blue);
btn4.setSize(80, 38);
btn4.setLocation(200, 230);
btn4.setFont(font);
btn4.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
new 更新();
m.setVisible(true);
}
});
m.add(l0);
m.add(l1);
m.add(tf1);
m.add(l2);
m.add(tf2);
m.add(l3);
m.add(tf3);
m.add(l4);
m.add(tf4);
m.add(l5);
m.add(tf5);
m.add(l6);
m.add(tf6);
m.add(l7);
m.add(tf7);
m.add(btn1);
m.add(btn2);
m.add(btn3);
m.add(btn4);
m.setVisible(true);
}
public static void main(String[] args) {
new Stmessege();
}
}
可以仿照我的做一下,希望采纳,我才一级哦
java考试系统要求有简答题或者程序设计题,SQL数据库
采用mvc设计模式即可。设计用户表,试题表,试卷表,考试表
然后系统分为教师和学生两种角色
阅卷采用自动阅卷和手动阅卷两种模式相结合
学生可以参加考试和查看成绩
教师可以发布试题到指定班级和时间
正在写一个Java考试系统,在这里想满足:当学生单击下一题后保留题目的答案,如何设计?
使用缓存就可以了,把题目的id保存到缓存里面,具体的题目还是在数据库里面,需要显示的时候根据id去调取数据
java程序设计题,求解答?
shape接口
圆类
矩形类
三角形类1
三角形类2
测试类
利用swing设计一个班级学生信息管理系统,一道JAVA题 求代码,不要废话
public class RandomUtils {
public static String randomId(){
Random random = new Random();
StringBuilder sb = new StringBuilder();
for (int i = 0; i 6; i++) {
sb.append(random.nextInt(10));
}
return sb.toString();
}
public static int randomIntId(){
Random random = new Random();
StringBuilder sb = new StringBuilder();
for (int i = 0; i 6; i++) {
sb.append(random.nextInt(10));
}
return Integer.parseInt(sb.toString());
}
public static String randomName(){
String[] name1 = {"赵","钱","孙","李","周","吴","郑","王","张","刘"};
String[] name2 = {"一","二","三","四","五","六","七","八","九","十"};
Random random = new Random();
StringBuilder sb = new StringBuilder();
sb.append(name1[random.nextInt(10)]);
sb.append(name2[random.nextInt(10)]);
sb.append(name2[random.nextInt(10)]);
return sb.toString();
}
public static String randomSex(){
Random random = new Random();
return random.nextInt(4)/2==0?"男":"女";
}
public static int randomAge(int min, int max){
Random random = new Random();
return random.nextInt(min) + max-min;
}
public static int randomScore(){
Random random = new Random();
return (int)(random.nextDouble()*100%100);
}
public static String randomAddress(){
String[] address1 = {"商业","红叶","安康","河南","长海","黄河","桐柏","科学","瑞达","花园"};
String[] address2 = {"东","南","西","北","中"};
String[] address3 = {"街","路","大道","巷"};
Random random = new Random();
StringBuilder sb = new StringBuilder();
sb.append(address1[random.nextInt(10)]);
sb.append(address2[random.nextInt(5)]);
sb.append(address3[random.nextInt(4)]);
sb.append(random.nextInt(1000)+1);
sb.append("号");
return sb.toString();
}
}
import javax.swing.*;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.table.DefaultTableModel;
import javax.swing.tree.DefaultMutableTreeNode;
import java.awt.*;
import java.util.*;
import java.util.List;
public class StudentManage extends JFrame{
public final static String[] CH_NUM = {"一","二","三","四","五","六","七","八","九","十"};
public final static String ROOT = "班级管理";
public final static int GRADE_NUM = 3;
public final static int CLASS_NUM = 3;
private MapString, ListStudent classes;
public StudentManage() {
setTitle("学生管理系统");
setSize(300, 300);
setLayout(new BorderLayout());
if(classes == null) classes = new HashMap();
DefaultMutableTreeNode top = new DefaultMutableTreeNode(ROOT);
DefaultMutableTreeNode[] gradeNodes = new DefaultMutableTreeNode[GRADE_NUM];
for (int i = 0; i GRADE_NUM; i++) {
gradeNodes[i] = new DefaultMutableTreeNode(CH_NUM[i] + "年级");
for (int j = 0; j CLASS_NUM; j++) {
gradeNodes[i].add(new DefaultMutableTreeNode(CH_NUM[j] + "班"));
}
top.add(gradeNodes[i]);
}
final JTree tree = new JTree(top);
String title[] = {"ID","姓名","性别","年龄","地址"};
final DefaultTableModel model = new DefaultTableModel(title, 0);
JTable table=new JTable(model);
tree.addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent e) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree .getLastSelectedPathComponent();
if (node == null) return;
Object object = node.getUserObject();
if (node.isLeaf()) {
ListStudent stdList = classes.get(getFullPath(node));
Object[][] data = new Object[stdList.size()][5];
for (int i = 0; i stdList.size(); i++) {
data[i][0] = stdList.get(i).getId();
data[i][1] = stdList.get(i).getName();
data[i][2] = stdList.get(i).getSex();
data[i][3] = stdList.get(i).getAge();
data[i][4] = stdList.get(i).getAddress();
}
while(model.getRowCount()0){
model.removeRow(model.getRowCount()-1);
}
for (int i = 0; i stdList.size(); i++) {
model.addRow(data[i]);
}
model.fireTableDataChanged();
}
}
});
add(tree, BorderLayout.WEST);
add(new JScrollPane(table), BorderLayout.CENTER);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
private String getFullPath(DefaultMutableTreeNode defaultMutableTreeNode){
StringBuilder sb = new StringBuilder();
Object[] objs = defaultMutableTreeNode.getUserObjectPath();
for (int i = 0; i objs.length; i++) {
sb.append(objs[i]);
}
return sb.toString().replace(ROOT,"");
}
public void init(){
for (int i = 0; i GRADE_NUM; i++) {
for (int j = 0; j CLASS_NUM; j++) {
int n = new Random().nextInt(30)+1;
ListStudent stdList = new ArrayList(n);
for (int k = 0; k n; k++) {
stdList.add(new Student(RandomUtils.randomIntId(),RandomUtils.randomName(),RandomUtils.randomSex(),
RandomUtils.randomAge(6,12),RandomUtils.randomAddress()));
}
classes.put(CH_NUM[i] + "年级"+ CH_NUM[j] +"班", stdList);
}
}
}
public static void main(String[] args) {
StudentManage studentManage = new StudentManage();
studentManage.init();
}
}
class Student {
private int id;
private String name;
private String sex;
private int age;
private String address;
public Student(int id, String name, String sex, int age, String address) {
this.id = id;
this.name = name;
this.sex = sex;
this.age = age;
this.address = address;
}
public Student() {
}
public int getId() {
return id;
}
public String getName() {
return name;
}
public String getSex() {
return sex;
}
public int getAge() {
return age;
}
public String getAddress() {
return address;
}
@Override
public String toString() {
return "Student{" +
"id=" + id +
", name='" + name + '\'' +
", sex='" + sex + '\'' +
", age=" + age +
", address='" + address + '\'' +
'}';
}
}
本文题目:java答题系统设计代码 java程序设计基础题库及答案
URL链接:http://azwzsj.com/article/hihedp.html