自己敲的代码。。暂时还不会修改问图形界面,——————未完成

论坛 期权论坛 脚本     
匿名网站用户   2020-12-20 11:13   68   0
// 设有李,王,张 三个人竞选领导,有群众投票表决,试设计一个统计选票的程序。

import javax.swing.*;
import java.io.*;

import javax.swing.JOptionPane;
public class a201603312
{
public static void main(String[] args)throws IOException
{
BufferedReader keyin = new BufferedReader(new InputStreamReader(System.in));
//上面一条语句是有关键盘输入数据流的处理的,详情在后面的输入 /输出流
int Ltotal = 0, Wtotal = 0 , Ztotal = 0;
char name ;
//String name;
String c1;
System.out.print("enter letter L or W or Z name ,# to end:");
c1 = keyin.readLine();
name = c1.charAt(0);
//name = JOptionPane.showInputDialog(null,"what is your name");
while (name!='#')
{
switch(name)
{
case 'L':
case 'l':
Ltotal = Ltotal + 1;
break;
case 'W':
case 'w':
Wtotal = Wtotal + 1;
break;
case 'Z':
case 'z':
Ztotal = Ztotal +1;
break;
}//switch 循环语句结束;

System.out.print("Enter letter L or W or Z name ,# to end:");
c1 = keyin.readLine();
name = c1.charAt(0);
}//while 循环结束s
System.out.println("Ltotal=" + Ltotal);
System.out.println("Wtotal=" + Wtotal);
System.out.println("Ztotal=" + Ztotal);
//JOptionPane.showMessageDialog(null, "Ltotal=" + Ltotal);
//自己还没有做完,在之后的时间中,根据前面的对话框,修改成带对话框的。
//import.javac.swing*;
//showConfirmFialog()用于询问一个确定的问题 如yes/no/cancel
//showInputDialog() 用于提示要求某些输入
//showMessageDialog() 告知用户某事已发生
//showOptionDialog() 上述三项的大统一
}

}

暂时不会修改成图形界面的,只能先在这里留下一个问号了。——————————————————————————————————————————————

————————————————————————————————————————————————————————————————————————————

——————————————————————————————————————————————————————————

——————————————————————————————


下面的供参考

+

+

+



//图形界面方法的输入,书上要求只做了解,不过兴趣使然,喜欢
import javax.swing.JOptionPane; //导入图形界面方法
public class a201604055
{
public static void main(String[] args)
{
String result;
result = JOptionPane.showInputDialog(null,"your name is?");
JOptionPane.showMessageDialog(null, "hello,"+result +"!");
}
}
//练习学习使用图形界面的应用。




分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:1136255
帖子:227251
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP