「java怎么写选择题系统」用java编写一道选择题

博主:adminadmin 2022-12-24 11:06:08 59

今天给各位分享java怎么写选择题系统的知识,其中也会对用java编写一道选择题进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

怎样用JAVA编选择题程序(急)

刚好我以前毕业设计做的是网上自测

从数据库中加载这些题

将每道题的四个选项放在input type="radio"/中

每道题的四个radio共享一个name属性,即可实现单选功能。这个name属性可以用jsp动态产生。

用户做完题提交后。服务器获得用户所选的radio的值,与数据库中的正确答案比较,再把比较的结果以及正确答案返回给用户。

不懂加我67919823

Java代码,运行程序,出来一些选择题,并能输入选项,系统给出得分? 没有代码说说怎么做也可以的,谢谢

为什么不首先设置一个欢迎界面呢?在欢迎界面上定义一个开始考试按钮,点击按钮跳转到考题页面,把所有的考题设置在一张表单里面,考题无非设置成一些单选或者多选的按钮。然后每个题目就是一个属性,获取验证,对了多少分,错误没分,然后统计下分数不就完了。希望对你设计有帮助哈。

用java编写一道选择题:

import java.util.Scanner;

public class Test22 {

public static void main(String[] args) {

System.out.println("白__依山尽");

System.out.println("黄河入海__");

System.out.println("欲穷千里__");

System.out.println("更__一层楼");

System.out.println("答案:");

System.out.println("A:日、流、目、上");

System.out.println("B:目、流、日、上");

System.out.println("C: 日、流、上、目");

System.out.println("D: 上、流、目、日");

System.out.print("请选择:");

Scanner scanner = new Scanner(System.in);

String input = scanner.next();

if("A".equals(input)) {

System.out.println("恭喜你答对了!");

} else {

System.out.println("很遗憾打错了!");

}

}

}

java中怎么编写多项选择题代码

import java.awt.Checkbox;

import java.awt.CheckboxGroup;

import java.awt.Choice;

import java.awt.FlowLayout;

import java.awt.Label;

import java.awt.TextField;

import java.awt.event.ItemEvent;

import java.awt.event.ItemListener;

import javax.swing.JFrame;

public class Choose extends JFrame implements ItemListener {

 /**

  * 

  */

 private static final long serialVersionUID = 1L;

 Label l1, l2;

 TextField t1, t2;

 CheckboxGroup checkboxGroup = new CheckboxGroup();

 Checkbox checkbox1 = new Checkbox("QQ", checkboxGroup, false);

 Checkbox checkbox2 = new Checkbox("MSN", checkboxGroup, false);

 Checkbox checkbox3 = new Checkbox("ICQ", checkboxGroup, false);

 Choice c;

 public Choose() {

  super("简单小程序");

  this.setLayout(new FlowLayout());

  l1 = new Label("选择你常用的软件:");

  l2 = new Label("选择你喜欢的水果:");

  checkbox1.addItemListener(this);

  checkbox2.addItemListener(this);

  checkbox3.addItemListener(this);

  t1 = new TextField(20);

  t2 = new TextField(20);

  c = new Choice();

  c.addItemListener(this);

  c.add("苹果");

  c.add("橘子");

  c.add("香蕉");

  c.add("梨子");

  this.add(l1);

  this.add(checkbox1);

  this.add(checkbox2);

  this.add(checkbox3);

  this.add(t1);

  this.add(l2);

  this.add(c);

  this.add(t2);

  this.setSize(450, 200);

  this.setVisible(true);

 }

 public static void main(String[] args) {

  new Choose();

 }

 public void itemStateChanged(ItemEvent e) {

  if (e.getSource() == checkbox1) {

   t1.setText("你常用的软件是:" + checkbox1.getLabel());

  }

  if (e.getSource() == checkbox2) {

   t1.setText("你常用的软件是:" + checkbox2.getLabel());

  }

  if (e.getSource() == checkbox3) {

   t1.setText("你常用的软件是:" + checkbox3.getLabel());

  }

  t2.setText("你喜欢的水果是:" + c.getSelectedItem());// 得到选中的下拉列表值

 }

}

JAVA如何写一个选择题?(最好可以自动循环的)

/**

* 额 java的 问题 怎么跑 来C++ 了?

* 我写的这个 你看下 符合不?

*

*/

import java.util.Scanner;

public class Test001 {

public static void main(String[] args) {

Scanner read=new Scanner(System.in);

int[] regionOne={1,2,3};

int[] regionTwo={4,5,6};

while(true){

System.out.println("以下数字属于哪个区?1-1区;2-2区");

int randomNum=(int)(Math.random()*6+1);

System.out.print(randomNum+" 所在的区是 :");

String input=read.nextLine();

try {

int answer=Integer.parseInt(input);

if(answer==1){

boolean rs=check(regionOne,randomNum);

if(rs){

System.out.println("正确");

}else{

System.out.println("输入错误:");

continue;

}

}else if(answer==2){

boolean rs=check(regionTwo,randomNum);

if(rs){

System.out.println("正确");

}else{

System.out.println("输入错误:");

continue;

}

}else{

System.out.println("输入不正确!");

}

} catch (Exception e) {

System.out.println("输入错误:");

}

}

}

private static boolean check(int[] region, int num) {

for(int i=0;iregion.length;i++){

if(region[i]==num){

return true;

}

}

return false;

}

}

java怎么写选择题系统的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于用java编写一道选择题、java怎么写选择题系统的信息别忘了在本站进行查找喔。

The End

发布于:2022-12-24,除非注明,否则均为首码项目网原创文章,转载请注明出处。