import java.util.Random;

創(chuàng)新互聯(lián)建站為企業(yè)級(jí)客戶提高一站式互聯(lián)網(wǎng)+設(shè)計(jì)服務(wù),主要包括成都網(wǎng)站制作、成都網(wǎng)站設(shè)計(jì)、app軟件定制開(kāi)發(fā)、重慶小程序開(kāi)發(fā)公司、宣傳片制作、LOGO設(shè)計(jì)等,幫助客戶快速提升營(yíng)銷(xiāo)能力和企業(yè)形象,創(chuàng)新互聯(lián)各部門(mén)都有經(jīng)驗(yàn)豐富的經(jīng)驗(yàn),可以確保每一個(gè)作品的質(zhì)量和創(chuàng)作周期,同時(shí)每年都有很多新員工加入,為我們帶來(lái)大量新的創(chuàng)意。
import java.util.Scanner;
public class MaxNumber {
private static Scanner input = new Scanner(System.in); // 實(shí)例控制臺(tái)輸入類(lèi)
public static void main(String[] args) {
/*
* 第一步, 按照題目要求 , 我們需要用戶輸入 10 個(gè)數(shù)字
*/
int[] numberArray = new int[10]; // 我們先定義一個(gè) 可以裝 10 個(gè)數(shù)字的數(shù)組
int choose = chooseMode(); // 我加了一個(gè)選擇模式的函數(shù)
if (choose == 1) { // 用戶手工輸入
for (int i = 0; i numberArray.length; i++) { // 循環(huán)輸入
System.out.print("請(qǐng)定義第 '" + (i + 1) + "' 個(gè)數(shù)字:"); // 輸出控制臺(tái)提示
numberArray[i] = input.nextInt(); // 要求輸入, 并存儲(chǔ)到數(shù)組變量里
}
} else { // 計(jì)算機(jī)隨機(jī)生成
Random random = new Random(); // 隨機(jī)數(shù)類(lèi)
int tempNumber = 0 ; // 臨時(shí)變量
for (int i = 0; i numberArray.length; i++) { // 計(jì)算機(jī)生成
tempNumber = random.nextInt(100) + 1; // 隨機(jī)生成 1 - 100 的數(shù)
System.out.println("計(jì)算機(jī)生成的第 '" + (i + 1) + "' 個(gè)數(shù)字是:" + tempNumber);
numberArray[i] = tempNumber; // 賦值
}
}
/*
* 第二步 , 找這 10 個(gè)數(shù)當(dāng)中 , 最大的數(shù).
*/
int maxNumber = 0; // 定義一個(gè)變量接收最大的數(shù)
for (int i = 0; i numberArray.length; i++) { // 循環(huán)尋找
/*
* 循環(huán)比對(duì), 一個(gè)接一個(gè)的, 如果 '當(dāng)前數(shù)' , 比我們已經(jīng)記錄的 '最大數(shù)' 還大, 那我們就把當(dāng)前數(shù) 賦給 最大數(shù)
*/
if (numberArray[i] maxNumber) {
maxNumber = numberArray[i];
}
}
System.out.println("其中最大的數(shù)是:" + maxNumber); // 輸出結(jié)果
}
/**
* 選擇模式方法
* @return 返回選擇的模式的編號(hào)
*/
public static int chooseMode() {
System.out.println("------------ 選擇模式 ------------");
System.out.println("\t1. 用戶輸入十個(gè)數(shù)字");
System.out.println("\t2. 計(jì)算機(jī)隨機(jī)產(chǎn)生十個(gè)數(shù)字");
System.out.print("請(qǐng)選擇:");
return input.nextInt(); // 輸入, 返回
}
/*
* 其中包函的知識(shí)有: 控制臺(tái)輸入, 輸出 , 數(shù)組 , 循環(huán) , if 判斷語(yǔ)句
*/
}
最后:
希望能幫到你,如果有什么問(wèn)題可以 Hi 我,
看到樓主花了怎么多耐心,寫(xiě)了怎么多判斷,也可以見(jiàn)得樓主確實(shí)用心了,
只是沒(méi)找到方法。
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("學(xué)號(hào):");
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("班級(jí):");
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("計(jì)算機(jī)工程系");
tf5.setForeground(Color.blue);
tf5.setBackground(Color.white);
tf5.setSize(80, 20);
tf5.setLocation(200, 170);
final Label l6 = new Label("成績(jī):");
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("專(zhuān)業(yè):");
l7.setSize(60, 20);
l7.setLocation(10, 230);
l7.setFont(font);
TextField tf7 = new TextField("軟件技術(shù)");
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("查詢學(xué)生學(xué)籍信息");
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();
}
}
可以仿照我的做一下,希望采納,我才一級(jí)哦
采用mvc設(shè)計(jì)模式即可。設(shè)計(jì)用戶表,試題表,試卷表,考試表
然后系統(tǒng)分為教師和學(xué)生兩種角色
閱卷采用自動(dòng)閱卷和手動(dòng)閱卷兩種模式相結(jié)合
學(xué)生可以參加考試和查看成績(jī)
教師可以發(fā)布試題到指定班級(jí)和時(shí)間
使用緩存就可以了,把題目的id保存到緩存里面,具體的題目還是在數(shù)據(jù)庫(kù)里面,需要顯示的時(shí)候根據(jù)id去調(diào)取數(shù)據(jù)
shape接口
圓類(lèi)
矩形類(lèi)
三角形類(lèi)1
三角形類(lèi)2
測(cè)試類(lèi)
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?=?{"趙","錢(qián)","孫","李","周","吳","鄭","王","張","劉"};
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?=?{"商業(yè)","紅葉","安康","河南","長(zhǎng)海","黃河","桐柏","科學(xué)","瑞達(dá)","花園"};
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("號(hào)");
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?=?"班級(jí)管理";
public?final?static?int?GRADE_NUM?=?3;
public?final?static?int?CLASS_NUM?=?3;
private?MapString,?ListStudent?classes;
public?StudentManage()?{
setTitle("學(xué)生管理系統(tǒng)");
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]?+?"年級(jí)");
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]?+?"年級(jí)"+?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答題系統(tǒng)設(shè)計(jì)代碼 java程序設(shè)計(jì)基礎(chǔ)題庫(kù)及答案
                
                URL網(wǎng)址:http://www.chinadenli.net/article18/hihedp.html
            
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供手機(jī)網(wǎng)站建設(shè)、做網(wǎng)站、用戶體驗(yàn)、網(wǎng)站制作、營(yíng)銷(xiāo)型網(wǎng)站建設(shè)、微信公眾號(hào)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)