我以前寫過超市掃碼的,首先得有一個(gè)掃碼槍,頁面上讓光標(biāo)在文本框內(nèi),按一下掃碼槍就會(huì)自動(dòng)將貨物的條形碼顯示在你的文本框中了,掃碼槍將條形碼顯示在文本框中默認(rèn)帶一個(gè)回車,你就用javascript觸發(fā)回車事件,寫一個(gè)方法,從后臺(tái)數(shù)據(jù)庫中根據(jù)條形碼查到具體的詳細(xì)信息顯示到頁面上就行了,用ajax提交

德宏州ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場(chǎng)景,ssl證書未來市場(chǎng)廣闊!成為創(chuàng)新互聯(lián)建站的ssl證書銷售渠道,可以享受市場(chǎng)價(jià)格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18980820575(備注:SSL證書合作)期待與您的合作!
package?entity;
public?class?Market?{
private?int?id;//id
private?int?num;//數(shù)量
private?String?goods;//商品
private?double?price;//價(jià)格
public?Market(int?id,?int?num,?String?goods,?double?price)?{
super();
this.id?=?id;
this.num?=?num;
this.goods?=?goods;
this.price?=?price;
}
public?int?getId()?{
return?id;
}
public?void?setId(int?id)?{
this.id?=?id;
}
public?int?getNum()?{
return?num;
}
public?void?setNum(int?num)?{
this.num?=?num;
}
public?String?getGoods()?{
return?goods;
}
public?void?setGoods(String?goods)?{
this.goods?=?goods;
}
public?double?getPrice()?{
return?price;
}
public?void?setPrice(double?price)?{
this.price?=?price;
}
public?double?calc(?){
double?sum=price*num;
System.out.println("您消費(fèi)共計(jì):"+sum+"¥");
return?sum;
}
}
package?test;
import?java.util.HashMap;
import?java.util.Map;
import?java.util.Scanner;
import?entity.Market;
public?class?Test?{
private?static?MapInteger,Market?goods=new?HashMapInteger,?Market();
public?static?void?main(String[]?args)?{
System.out.println("-------超市計(jì)價(jià)系統(tǒng)-------");
String?goods1="可口可樂";
String?goods2="爆米花";
String?goods3="益達(dá)";
printTable("編號(hào)","商品","價(jià)格");
printTable("1",goods1,"3.0¥");
printTable("2",goods2,"5.0¥");
printTable("3",goods3,"10.0¥");
goods.put(1,?new?Market(1,?1,?goods1,?3.0));
goods.put(2,?new?Market(2,?1,??goods2,?5.0));
goods.put(3,?new?Market(3,?1,?goods3,?10.0));
Scanner?input?=?new?Scanner(System.in);
System.out.println("請(qǐng)輸入商品的編號(hào):");
int?num?=?input.nextInt();
System.out.println("請(qǐng)輸入商品的數(shù)量");
int?amount?=?input.nextInt();
Market?market?=?goods.get(num);
market.setNum(amount);
market.calc();
}
private?static?void?printTable(String?row1,String?row2,String?row3?)?{
System.out.print(row1);
int?times=12;
if?(row2!="商品")?{
times=5;
}
for?(int?i?=?0;?i??times;?i++)?{
System.out.print("?");
}
System.out.print(row2);
for?(int?i?=?0;?i??10;?i++)?{
System.out.print("?");
}
System.out.print(row3);
System.out.println("\n");
}
}
//測(cè)試結(jié)果:
-------超市計(jì)價(jià)系統(tǒng)-------
編號(hào)????????????商品??????????價(jià)格
1?????可口可樂??????????3.0¥
2?????爆米花??????????5.0¥
3?????益達(dá)??????????10.0¥
請(qǐng)輸入商品的編號(hào):
3
請(qǐng)輸入商品的數(shù)量
5
您消費(fèi)共計(jì):50.0¥
要使用Java編寫超市購物程序,您需要使用Java數(shù)據(jù)庫編程技術(shù)來連接到您的數(shù)據(jù)庫并執(zhí)行相關(guān)的數(shù)據(jù)庫操作。在Java中,您可以使用JDBC(Java數(shù)據(jù)庫連接)API來連接到數(shù)據(jù)庫并執(zhí)行SQL語句。例如,您可以使用JDBC API來執(zhí)行以下操作:
創(chuàng)建數(shù)據(jù)庫連接
執(zhí)行增刪改查(CRUD)操作
提交或回滾事務(wù)
執(zhí)行存儲(chǔ)過程和函數(shù)
查詢數(shù)據(jù)庫元數(shù)據(jù)
此外,您還可以使用Java的面向?qū)ο缶幊碳夹g(shù)來封裝數(shù)據(jù)庫操作,以便更方便地在您的程序中使用。例如,您可以創(chuàng)建一個(gè)類來表示超市商品,并定義一些方法來執(zhí)行商品的增刪改查操作。這樣,您就可以在程序中通過調(diào)用這些方法來簡(jiǎn)單地完成對(duì)數(shù)據(jù)庫的操作,而不需要編寫復(fù)雜的SQL語句。
條形碼是按條的寬度和間隔來表示信息,分析圖片的象素,通過象素的長(zhǎng)度來判斷條的寬度和間隔,根據(jù)一定的標(biāo)準(zhǔn)來轉(zhuǎn)換成字符串……但是,識(shí)別的錯(cuò)誤率會(huì)相當(dāng)高了,因?yàn)闂l形碼圖片是通過掃描儀掃出來的,本身就會(huì)有誤差!
當(dāng)前文章:java超市掃碼代碼 java超市購物程序
網(wǎng)頁地址:http://www.yijiale78.com/article24/ddocdce.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供Google、面包屑導(dǎo)航、外貿(mào)網(wǎng)站建設(shè)、企業(yè)網(wǎng)站制作、域名注冊(cè)、網(wǎng)頁設(shè)計(jì)公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)