public class Lucky {
創(chuàng)新互聯(lián)主要從事網(wǎng)站設(shè)計(jì)、成都網(wǎng)站制作、網(wǎng)頁(yè)設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)茫崖,10多年網(wǎng)站建設(shè)經(jīng)驗(yàn),價(jià)格優(yōu)惠、服務(wù)專業(yè),歡迎來(lái)電咨詢建站服務(wù):028-86922220
public static void main(String[] args){
System.out.println("請(qǐng)輸入您的4位會(huì)員卡號(hào):");
Scanner sc = new Scanner(System.in);
int number = sc.nextInt(); //接收用戶從控制臺(tái)輸入的會(huì)員卡號(hào),并保存在會(huì)員卡號(hào)變量中
int a = number/1000; //千位
int b = number%1000/100; //百位
int c = number%100/10; //十位
int d = number%10; //個(gè)位
if((a+b+c+d)20){
System.out.println("恭喜中獎(jiǎng)!您是幸運(yùn)客戶");
}else{
System.out.println("謝謝參與!");
}
}
}
最基礎(chǔ)的 沒(méi)有異常判斷 無(wú)限循環(huán)輸入什么東西
算是最簡(jiǎn)單的吧
package cn.job01;
import java.util.Scanner;
public class Lx07 {
public static void choice() {
System.out.println("登陸菜單 ");
System.out.println("1登陸系統(tǒng)");
System.out.println("2退出");
}
static void choice1() {
System.out.println("購(gòu)物管理系統(tǒng)客戶信息");
System.out.println("1顯示所有客戶信息");
System.out.println("2添加客戶信息");
System.out.println("3修改客戶信息");
System.out.println("4查詢客戶信息");
}
static void choice2() {
System.out.println("購(gòu)物管理系統(tǒng)真情回饋");
System.out.println("1幸運(yùn)大放送");
System.out.println("2幸運(yùn)抽獎(jiǎng)");
System.out.println("3生日問(wèn)候");
}
public static void main(String[] args) {
choice();
Scanner input = new Scanner(System.in);
System.out.println("請(qǐng)輸入1or2");
int num = input.nextInt();
switch (num) {
case 1:
System.out.println("主菜單");
System.out.println("1客戶信息管理");
System.out.println("2購(gòu)物結(jié)算");
System.out.println("3真情回饋");
System.out.println("4注銷");
break;
}
System.out.println("選擇輸入數(shù)字");
int num1 = input.nextInt();
switch (num1) {
case 1:
choice1();
break;
case 2:
System.out.println("購(gòu)物結(jié)算");
break;
case 3:
choice2();
break;
case 4:
choice();
break;
}
}
}
import java.util.Scanner;
public class AddCustomer{
public static void main(String[] args){
System.out.printIn("MyShopping管理系統(tǒng) 客戶信息管理 添加客戶信息\n");
int custNo; //會(huì)員號(hào)
int birthday; //會(huì)員生日
int points = 0; //會(huì)員積分
Scanner input=new Scanner(System.in);
for(int i=0;i3;i++){ //循環(huán)錄入會(huì)員信息
System.out.printIn("請(qǐng)輸入會(huì)員號(hào)(4位整數(shù)):");
custNo = input.nextInt();
System.out.printIn("請(qǐng)輸入會(huì)員生日(月\日用兩位整數(shù)表示):");
custNo = input.next();
System.out.printIn("請(qǐng)輸入會(huì)員積分:");
custNo = input.nextInt();
if(custNo1000||custNo9999){ //會(huì)員號(hào)無(wú)效則跳出
System.out.printIn("客戶號(hào)"+custNo+"是無(wú)效會(huì)員號(hào)!");
System.out.printIn("錄入信息失敗\n");
contiune;
}
System.out.printIn("您錄入的會(huì)員信息是:");
System.out.printIn(custNo+" "+birthday+" "+points+ "\n");
}
System.out.printIn("程序結(jié)束!");
}
}
現(xiàn)在比較有名的有千米網(wǎng)B2C商城系統(tǒng)是Java開(kāi)發(fā)的,ecshop商城系統(tǒng)是PHP開(kāi)發(fā)的。相對(duì)來(lái)說(shuō)比較推薦千米的Java商城系統(tǒng),各種功能都很齊全,而且易操作上手,安全性也有保障。具體的商城類型可以做獨(dú)立商城,也可以做多用戶商城,比如京東的模式。
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="可口可樂(lè)";
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?????可口可樂(lè)??????????3.0¥
2?????爆米花??????????5.0¥
3?????益達(dá)??????????10.0¥
請(qǐng)輸入商品的編號(hào):
3
請(qǐng)輸入商品的數(shù)量
5
您消費(fèi)共計(jì):50.0¥