当前位置:首页 » 操作系统 » 手机投票源码

手机投票源码

发布时间: 2023-12-01 03:06:29

A. java做投票系统

java做投票系统,设计程序如下:

import java.util.Set; //调用java.util.Set
import java.util.HashSet;//调用java.util.HashSet
import java.util.Iterator;//调用java.util.Iterator

public class Voter { //定义类
private static final int MAX_COUNT=100; //静态变量,最大投票数,到达此数就停止投票
private static int count; //静态变量,投票数
private static Set<Voter>voters=new HashSet<Voter>(); //静态变量,存放所有已经投票的选民
private String name; //实例变量,投票人姓名

public Voter(String name){this.name=name;} //定义名字字符串函数

/**投票*/
public void voteFor(){ //投票函数
if(count==MAX_COUNT){ //如果计数结果等于投票人数最大值
System.out.println("投票活动已经结束"); //打印投票活动已经结束
return; //返回主函数
}
if(voters.contains(this)) //如果已包含投票人姓名
System.out.println(name+":你不允许重复投票!"); //打印投票人姓名和你不允许重复投票!
else{ //否则
count++; //计数加一
voters.add(this); //调用字符串函数添加投票人姓名
System.out.println(name+":感谢你投票!"); //打印投票人姓名和感谢你投票!
}
}

/**打印投票结果*/
public static void printVoteResult(){ //投票结果函数
System.out.println("当前投票数为:"+count); //打印当前投票数为,并且统计人数
System.out.println("参与投票的选民名单如下"); //打印参与投票的选民名单如下
for(Voter voter:voters){ //遍历voters集合
System.out.println(voter.name); //打印输出投票名称
}
}

public static void main(String args[]) { //主函数
Voter tom=new Voter("Tom"); //开辟空间定义元素tom
Voter mike=new Voter("Mike"); //开辟空间定义元素mike
Voter jack=new Voter("Jack"); //开辟空间定义元素jack

tom.voteFor(); //进入tom的投票函数
tom.voteFor(); //进入tom的投票函数
mike.voteFor(); //进入mike的投票函数
jack.voteFor(); //进入jack的投票函数

Voter.printVoteResult(); //投票结果打印函数

}

}

B. 投票统计器(c++源代码)

如果你文本文件内的名字中间用空格隔开就好了,很容易实现统计的

这是加了空格后的统计

这样的效果可以吗

C. 跪求html简洁投票系统源码,我已经在网上找了6天了,脑壳青痛!

六天,看来你够苦的.帮你一下,用application做的,不知你是否满意,
首先在你网站根目录下新建一个名为:Global.asa的文件,然后把下列代码贴上去:
<script language="vbscript" runat="server">
Sub Application_OnStart
application("yes")=0
application("no")=0
End Sub
</script>

然后再建一个投票的ASP文件,内容:
<style type="text/css">
<!--
.Vote {
height: 15px;
width: 200px;
border: 1px solid #0033FF;
}
#cYes {
background-color: #FF6600;
height: 15px;
width: 100px;
}
#cNo {
background-color: #FF6600;
height: 15px;
width: 100px;
}
-->
</style>
<form action="" method="post">
做一个投票系统难吗?<br />
<input name="yes" type="radio" value="yes" onclick="if (this.checked==true) no.checked=false;" />赞成<br />
<input name="no" type="radio" value="no" onclick="if (this.checked==true) yes.checked=false;"/>反对<br />
<input name="投票" type="submit" value="投票" />
</form>
<%
nyes=0
nNo=0
'如果想重新计票,用下面四行
'application.lock()
'application("yes")=application("yes")+1
'application("no")=application("no")+1
'application.unlock()

count=application("yes")+application("no")
if count<>0 then
nyes=int(application("yes")*200/count)
nNo=int(application("no")*200/count)
end if

sYes=Request.form("yes")
sNo=Request.form("no")
act= Request.form("投票")
if act="投票" Then
if sYes="yes" Then
application.lock()
application("yes")=application("yes")+1
application.unlock()
Else
if sNo="no" then
application.lock()
application("no")=application("no")+1
application.unlock()
end if
End if
'图形化显示投票结果
count=application("yes")+application("no")
if count<>0 then
nyes=int(application("yes")*200/count)
nNo=int(application("no")*200/count)
end if
end if
%>

赞成:<%=application("yes")%>票
<div class="Vote" ><div ID="cYes" neme="cYes" style="width:<%=nyes%>px;"></div></div>
反对::<%=application("no")%>票
<div class="Vote" ><div ID="cNo" neme="cNo" style="width:<%=nNo%>px;"></div></div>

D. jsp投票系统求源代码!可以连数据库的!

<p style=line-height: 150%><SPAN style="FONT-SIZE: 12px"><STRONG>这是用文本文件作为存储载体的投票系统:</STRONG></SPAN>
<p style=line-height: 150%><SPAN style="FONT-SIZE: 12px"><STRONG>vote.java:</STRONG></SPAN>
<SPAN style="FONT-SIZE: 12px"><STRONG></STRONG> <p style=line-height: 150%>
// Java Document
package vote;
import java.io.*;
import java.util.*;
public class vote extends Object
{
public String filePath="";
public int n;
private File voteFile;
private BufferedReader fileRead;
private PrintWriter fileWrite;
public String systemMessage="";
private String voteStr[]=new String[10];
public int voteNum[]=new int[10];
public void createFile()
throws FileNotFoundException
{
voteFile=new File(filePath);
if(!voteFile.exists())
{
fileWrite=new PrintWriter(new FileOutputStream(filePath));
for(int i=0;i<n;i++) fileWrite.println("0");
fileWrite.close();
}
}
public void writeFile()
throws FileNotFoundException
{
fileWrite=new PrintWriter(new FileOutputStream(filePath));
for(int i=0;i<n;i++)
{
fileWrite.println(voteNum[i]);
}
fileWrite.close();
}
public void readFile()
throws FileNotFoundException
{
fileRead=new BufferedReader(new FileReader(filePath));
for(int i=0;i<n;i++)
{
try
{voteStr[i]=fileRead.readLine();
}
catch(IOException f)
{
voteStr[i]="0";}
voteNum[i]=Integer.parseInt(voteStr[i]);
}
try
{
fileRead.close();
}
catch(IOException d)
{
systemMessage=d.toString();
}
}
}
<p style=line-height: 150%><SPAN style="LINE-HEIGHT: 15pt"><SPAN style="FONT-SIZE: 12px"><STRONG>vote.jsp:</STRONG>

<%@ page contentType="text/html; charset=gb2312" language="java" errorPage="" %>
<%@ page import="java.util.*"%>
<%@ page import="java.lang.*"%>
<%@ page import="java.io.*"%>
<jsp:useBean id="vote" scope="request" class="vote.vote"/>
<%
String vote1=request.getParameter("lang");
vote.n=4;
vote.filePath="vote.txt";
vote.createFile();
vote.readFile();
if(vote1.compareTo("0")==0)
vote.voteNum[0]++;
if(vote1.compareTo("1")==0)
vote.voteNum[1]++;
if(vote1.compareTo("2")==0)
vote.voteNum[2]++;
if(vote1.compareTo("3")==0)
vote.voteNum[3]++;
vote.writeFile();
%>
<script language="javascript">
alert("感谢你投了宝贵的一票");
self.location="index.jsp";
</script></SPAN></SPAN>
<p style=line-height: 150%><STRONG> </STRONG><SPAN style="LINE-HEIGHT: 15pt"><SPAN style="FONT-SIZE: 12px"><STRONG>see.jsp:</STRONG>

<%@ page contentType="text/html; charset=gb2312" language="java" errorPage="" %>
<%@ page import="java.util.*"%>
<%@ page import="java.lang.*"%>
<%@ page import="java.io.*"%>
<jsp:useBean id="vote" scope="request" class="vote.vote"/>
<%
String vote1=request.getParameter("lang");
vote.n=4;
vote.filePath="vote.txt";
vote.createFile();
vote.readFile();
int total=0;
float voteFlo[]=new float[5];
for(int i=0;i<4;i++) total+=vote.voteNum[i];
for(int i=0;i<4;i++) voteFlo[i]=150*((float)vote.voteNum[i]/(float)total);
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>查看调查</title>
<link href="t1.css" rel="stylesheet" type="text/css">
</head>
<body>

<table width="30%" border="0" class="t1">
<tr>
<td colspan="2"><div align="center">调查结果</div></td>
</tr>
<tr>
<td width="18%">JSP</td>
<td width="82%"><img src="bar.gif" width=<%=voteFlo[0]%> height=8> <%=vote.voteNum[0]%></td>
</tr>
<tr>
<td>ASP</td>
<td><img src="bar.gif" width=<%=voteFlo[1]%> height=8> <%=vote.voteNum[1]%></td>
</tr>
<tr>
<td>PHP</td>
<td><img src="bar.gif" width=<%=voteFlo[2]%> height=8> <%=vote.voteNum[2]%></td>
</tr>
<tr>
<td>其他</td>
<td><img src="bar.gif" width=<%=voteFlo[3]%> height=8> <%=vote.voteNum[3]%></td>
</tr>
<tr>
<td colspan="2"><div align="center"><a href="javascript:window.close();">关闭窗口</a></div></td>
</tr>
</table>
</body>
</html>
</SPAN></SPAN>
<p style=line-height: 150%><SPAN style="LINE-HEIGHT: 15pt"><SPAN style="FONT-SIZE: 12px"><SPAN style="LINE-HEIGHT: 15pt"><SPAN style="FONT-SIZE: 12px"><STRONG>index.jsp:</STRONG>
</SPAN></SPAN>
</SPAN></SPAN> <p style=line-height: 150%><SPAN style="LINE-HEIGHT: 15pt"><SPAN style="FONT-SIZE: 12px"><%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>投票</title>
<link href="t1.css" rel="stylesheet" type="text/css">
</head>
<script language="javascript">
function cw()
{window.open("see.jsp","mywindow","toolbar=no,left=150,top=200,width=270,height=350,menubar=no,systemMenu=no");
}
</script>
<body>
<table width="15%" height="250" align="left">
<tr>
<td><form name="form1" method="post" action="vote.jsp">
<table width="100%" height="250" border="1" align="center" bordercolor="#9966CC" class="t1">
<tr>
<td><div align="left">你所使用的开发语言</div></td>
</tr>
<tr>
<td><input type="radio" name="lang" value="0">
JSP</td>
</tr>
<tr>
<td><input type="radio" name="lang" value="1">
ASP</td>
</tr>
<tr>
<td><input type="radio" name="lang" value="2">
PHP</td>
</tr>
<tr>
<td><input type="radio" name="lang" value="3">
其他 </td>
</tr>
<tr>
<td><div align="center">
<input name="vote" type="image" src="poll.gif" width="40" height="20" border="0">
<a href="javascript:cw()"><img src="see.gif" width="40" height="20" border="0"></a></div></td>
</tr>
</table>
</form></td>
</tr>
</table>
</body>
</html>
</SPAN></SPAN></SPAN>

E. 网站投票系统源代码(java web)

http://www.onegreen.net/code/HTML/10633.html 你看看这个行不行 如果行的话 请采纳

热点内容
linux下ntp服务器搭建 发布:2024-09-08 08:26:46 浏览:742
db2新建数据库 发布:2024-09-08 08:10:19 浏览:171
频率计源码 发布:2024-09-08 07:40:26 浏览:778
奥迪a6哪个配置带后排加热 发布:2024-09-08 07:06:32 浏览:101
linux修改apache端口 发布:2024-09-08 07:05:49 浏览:209
有多少个不同的密码子 发布:2024-09-08 07:00:46 浏览:566
linux搭建mysql服务器配置 发布:2024-09-08 06:50:02 浏览:995
加上www不能访问 发布:2024-09-08 06:39:52 浏览:811
银行支付密码器怎么用 发布:2024-09-08 06:39:52 浏览:513
苹果手机清理浏览器缓存怎么清理缓存 发布:2024-09-08 06:31:32 浏览:554