java數(shù)據(jù)條形統(tǒng)計代碼 java統(tǒng)計文件的行數(shù)和字數(shù)
求Java大神給個代碼!計算驗證條形碼
public class Ean13Barcode {
10年積累的網(wǎng)站設計制作、做網(wǎng)站經(jīng)驗,可以快速應對客戶對網(wǎng)站的新想法和需求。提供各種問題對應的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡服務。我雖然不認識你,你也不認識我。但先做網(wǎng)站設計后付款的網(wǎng)站建設流程,更有圖木舒克免費網(wǎng)站建設讓你可以放心的選擇與我們合作。
private String code;
public Ean13Barcode(String code) {
super();
this.code = code;
}
public String encode() {
if (null == code) {
return "";
}
char[] codes = code.toCharArray();
int sum = 0;
for (int i = 0; i codes.length; i++) {
int num = codes[i] - '0';
if (isEven(num)) {
sum += num;
} else {
sum += num * 3;
}
}
int x = sum % 10;
return code + (x == 0 ? 0 : 10 - x);
}
private boolean isEven(int x) {
return x % 2 == 0;
}
public static void main(String[] args) {
System.out.println(new Ean13Barcode("692223361219").encode());
}
}
java :list集合中有100條數(shù)據(jù),每20條為一組取出來如何實現(xiàn)(具體代碼)
這個要看你要哪些成為一組了,比如說你要1-20的為一組,你在是for循環(huán)里面寫上if語句判斷即可,if(i=20),
再
if(i=40i20),
if(i=60i40),if(i=80i60),
if(i=100i80),
每條if中寫一條輸出語句,那么就分五組輸出了,希望你成功
如下是代碼:
ListInteger
sList=
new
ArrayListInteger();
for
(int
i
=
1;
i
=
100;
i++)
{
sList.add(i);//這里存了100個數(shù)
}
for
(int
i
=
1;
i
sList.size();
i++)
{
if(i=20)
{
System.out.println("第一組=="+sList.get(i));
}
if(i=40i20)
{
System.out.println("第二組=="+sList.get(i));
}
if(i=60i40)
{
System.out.println("第三組=="+sList.get(i));
}
if(i=80i60)
{
System.out.println("第四組=="+sList.get(i));
}
if(i=100i80)
{
System.out.println("第五組=="+sList.get(i));
}
}
Java如何進行數(shù)據(jù)庫里的數(shù)據(jù)統(tǒng)計
你這個跟java沒什么關系,數(shù)據(jù)庫自己就能實現(xiàn)。
T-SQL這樣寫就可以了
select * into table2 from table1
where (time3:00 and time5:00) --這句是偽代碼,你把條件改對
如果要統(tǒng)計數(shù)據(jù)條數(shù),另寫一條sql查。
如果table2已經(jīng)建好,請先刪除。
-------------------------------------------------------
這還不簡單啊,把上面的內(nèi)容組合一下。
select count(*) as count_num from table1 where (你的條件)
--這句得到數(shù)據(jù)條數(shù)了。
再加上這句
select no,time from table1 where (你的條件)
--這句得到所有符合條件的數(shù)據(jù)。
插入也可以用子查詢
--假設table2的id是自增的
insert into table2(no,time) values(
select no,time from table1 where(你的條件)
)
你在java里通過這些查詢已經(jīng)得到你要的數(shù)據(jù)了,再處理下就行了。
也可以把所有的查詢都變成子查詢?nèi)缓蠓诺揭粋€SQL語句里面,不過好象沒必要。
一個list里有20條數(shù)據(jù),每頁顯示六條,用Java寫出來一個簡單代碼,求告知
import?java.util.*;
public?class?Main?{
public?static?void?main(String[]?args)?{
//建假數(shù)據(jù)
ListInteger?list?=?new?ArrayList();
for?(int?i?=?1;?i??21;?i++)?{
list.add(i);
}
//分頁查找
ListInteger?data?=?getData(2,?6,?list);
if?(data.size()??0)?{
for?(Integer?integer?:?data)?{
System.out.println(integer);
}
}
}
/**
*?分頁查找
*?@param?page?第幾頁
*?@param?num?每頁數(shù)據(jù)數(shù)量
*?@param?list?數(shù)據(jù)源
*?@return
*/
public?static?ListInteger?getData(Integer?page,Integer?num,ListInteger?list){
//驗證參數(shù)
if?(page??0?||?num??0||list.size()1)?{
return?new?ArrayList();
}
//結果
ListInteger?rs?=?new?ArrayList();
Integer?start?=?(page-1)?*?num;
for?(int?i?=?start;?i??start+num?;?i++)?{
if?(i?==?list.size())?{
break;
}
rs.add(list.get(i));
}
return?rs;
}
}
如何使用java程序畫出條形統(tǒng)計圖(我們老師要求我們用java實現(xiàn)條形統(tǒng)計圖,數(shù)據(jù)來自于sqlserver中)
條形統(tǒng)計圖是用一個單位長度表示一定的數(shù)量,根據(jù)數(shù)量的多少畫成長短不同的直條,然后把這些直條按一定的順序排列起來。從條形統(tǒng)計圖中很容易看出各種數(shù)量的多少。條形統(tǒng)計圖一般簡稱條形圖,也叫長條圖或直條圖。條形統(tǒng)計圖是用條形的長短來代表數(shù)量的大小,便于比較。條形統(tǒng)計圖又分為條形統(tǒng)計圖和復式條形統(tǒng)計圖,復式條形統(tǒng)計圖由多種數(shù)據(jù)組成,用不同的顏色標出。
所填答案為:一定的數(shù)量 數(shù)量的多少 一定的順序
java編寫一個成績統(tǒng)計程序
import java.util.Scanner;
public class test {
static int s;
public static void main(String[] argv) {
int [] num=new int[20];
Scanner scanner=new Scanner(System.in);
Integer a;
int i;
for(i=1;i=20;i++){
System.out.println("請輸入第"+i+"一個分數(shù)(結束請輸入520嘿嘿):");
a=scanner.nextInt();
num[i-1]=a;
if(a==520){
break;
}
}
for(int m=0;mi-1;m++)
{
s=s+num[m];
}
System.out.println("總共錄入了"+(i-1)+"個分數(shù)");
System.out.println("總成績是"+s+"分");
System.out.println("平均分是"+s/(i-1)+"分");
for(Integer m=0;mnum.length-1;m++)
{ if(num[m]0num[m]!=520){
if(num[m]=90)
System.out.println(num[m]+"優(yōu)秀");
else if(num[m]=80)
System.out.println(num[m]+"良好");
else if(num[m]=70)
System.out.println(num[m]+"中等");
else if(num[m]=60)
System.out.println(num[m]+"及格");
else
System.out.println(num[m]+"不及格");
}else break;
}
}
}
我的代碼很簡潔,采納我唄。。。
本文題目:java數(shù)據(jù)條形統(tǒng)計代碼 java統(tǒng)計文件的行數(shù)和字數(shù)
當前路徑:http://www.xueling.net.cn/article/hipogh.html