目录
1.问题案例A:编程实现:随机生成n个整数,再从这n个整数中随机生成并输出1个数
实验目的:无
实验准备:敏捷开发,结对编程
实验内容:
1.问题案例A:编程实现:随机生成n个整数,再从这n个整数中随机生成并输出1个数
要求:略
代码:
package zy;
import java.util.Random;
import java.util.Scanner;
public class random_number {
public static void main(String args[]){
Scanner in = new Scanner(System.in);
System.out.println("最小数字:");
int start = in.nextInt();
System.out.println("最大数字:");
int end = in.nextInt();
if(getrandom(start,end)<0){
System.out.println("Data error!");
}
else{
System.out.println("输出随机数:"+getrandom(start,end));
}
}
private static int getrandom(int min,int max){
Random random = new Random();
int i = random.nextInt(max - min + 1)+min;
return i;
}
}
截图
2.问题案例B:
要求:
编程实现一个智能监控系统的用户登录 模块UI,设计效果及要求:
(1)
(2)
(3)
(4)
(5)
(6)
代码:
from tkinter import *
def login():
s1 = e1.get()
s2 = e2.get()
t1= len(s1)
t2 = len(s2)
if s1 == 'zy' and s2 == '666':
c['text'] = '登录成功'
def quit():
exit()
root = Tk() # 主界面
w1 = Label(root,text='用户登录',background='blue')
w1.grid(row=0,column=0,sticky=E)
root.wm_title('智能监控系统')
l = Label(root,text='用户名:') # 用户名的label
l.grid(row=1,column=0,sticky=W)
e1 = Entry(root)
e1.grid(row=1,column=1,sticky=E)
l2 = Label(root,text='密码:') # 密码的label
l2.grid(row=2,column=0,sticky=W)
e2 = Entry(root)
e2['show'] = '*'
e2.grid(row=2,column=1,sticky=E)
b = Button(root,text='登录',command=login)
b.grid(row=3,column=2,sticky=E)
c = Label(root,text='')
c.grid(row=3)
d = Button(root,text='取消',command=quit)
d.grid(row=3,column=1,sticky=E)
root.mainloop()
截图
3.请将下列内容译成中文
略
实验思考:
1.结合设计实践,
2.在软件实现过程中,