import?java.util.Scanner;
成都創(chuàng)新互聯(lián)專注于儀隴網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗(yàn)。 熱誠為您提供儀隴營銷型網(wǎng)站建設(shè),儀隴網(wǎng)站制作、儀隴網(wǎng)頁設(shè)計(jì)、儀隴網(wǎng)站官網(wǎng)定制、成都微信小程序服務(wù),打造儀隴網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供儀隴網(wǎng)站排名全網(wǎng)營銷落地服務(wù)。
//看這樣的行嗎?
public?class?StoreCharge?{
public?static?void?main(String[]?args)?{
Scanner?sc?=?new?Scanner(System.in);
System.out.println("輸入應(yīng)付金額:");
double?x?=?sc.nextDouble();
Price?p1?=?ampayable(x);
System.out.println(p1.toString());
System.out.println("輸入實(shí)付金額:");
double?y?=?sc.nextDouble();
Price?p2?=?ampaid(y);
System.out.println(p2.toString());
System.out.println("找零:"+charge(p1,p2).toString());
charge(p1,p2);
}
public?static?Price?charge(Price?p1,Price?p2){//p1總貨價(jià)?p2收款
int?c,b;
if(p2.connerp1.conner){
b?=?p2.conner+10-p1.conner;
p2.element?=?p2.element-1;
}else
b?=?p2.conner-p1.conner;
c?=?p2.element?-?p1.element;
return?new?Price(c,b);????????
}
public?static?Price?ampayable(double?x){//應(yīng)付金額
Price?a?=?new?Price();
a.element?=?(int)x;
a.conner??=?(int)(x*10?-((int)x)*10);
return?a;
}
public?static?Price?ampaid(double?x){//實(shí)付金額
Price?a?=?new?Price();
a.element?=?(int)x;
a.conner??=?(int)(x*10?-((int)x)*10);
return?a;
}
}
class?Price{
int?element;//元
int?conner;//角
public?Price(){}
public?Price(int?e,int?c){
element?=?e;
conner?=?c;
}
public?String?toString(){
return?element+"元"+conner+"角";
}
}
package?c;
import?java.util.Scanner;
public?class?SuperMarket?{
static?Scanner?scan?=?new?Scanner(System.in);
public?static?String?str;
public?static?void?main(String[]?args)?{
showMsg();
while?(scan.hasNext())?{
switch?(scan.nextInt())?{
case?1:
commodityManage();
break;
case?2:
customerManage();
break;
case?3:
orderManage();
break;
case?4:
exitSystem();
break;
default:
System.out.println("輸入錯(cuò)誤,請重新輸入!");
break;
}
}
scan.close();
}
/**
?*?顯示信息
?*/
public?static?void?showMsg()?{
System.out.println("===================================");
System.out.println("\t超??市??庫??存??管??理??系??統(tǒng)\t");
System.out.println("===================================");
System.out.println("1、商品管理");
System.out.println("2、客戶管理");
System.out.println("3、訂單管理");
System.out.println("4、退出系統(tǒng)");
System.out.println("===================================");
System.out.println("請輸入您的選擇(1-4):");
}
/**
?*?選項(xiàng)?1、商品管理
?*/
public?static?void?commodityManage()?{
str?=?"商品管理";
showWelcom(str);
System.out.println("以上為商品管理的信息!\n是否繼續(xù)?(按1繼續(xù)/其他結(jié)束):");
exitOrShow(1);
}
/**
?*?選項(xiàng)?2、客戶管理
?*/
public?static?void?customerManage()?{
str?=?"客戶管理";
System.out.println("以上為客戶管理的信息!\n是否繼續(xù)?(按2繼續(xù)/其他結(jié)束):");
exitOrShow(2);
}
/**
?*?選項(xiàng)?3、訂單管理
?*/
public?static?void?orderManage()?{
str?=?"訂單管理";
System.out.println("以上為訂單管理的信息!\n是否繼續(xù)?(按3繼續(xù)/其他結(jié)束):");
exitOrShow(3);
}
/**
?*?選項(xiàng)?4、退出系統(tǒng)
?*/
public?static?void?exitSystem()?{
System.exit(0);
}
public?static?void?showWelcom(String?str)?{
System.out.println("歡迎進(jìn)入"+?str?+"模塊");
System.out.println("===================================");
}
public?static?void?exitOrShow(int?nextInt)?{
if?(scan.nextInt()?!=?nextInt)?{
exitSystem();
}?else?{
showMsg();
}
}
}
import java.util.Scanner;
public class AddCustomer{
public static void main(String[] args){
System.out.printIn("MyShopping管理系統(tǒng) 客戶信息管理 添加客戶信息\n");
int custNo; //會(huì)員號
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("請輸入會(huì)員號(4位整數(shù)):");
custNo = input.nextInt();
System.out.printIn("請輸入會(huì)員生日(月\日用兩位整數(shù)表示):");
custNo = input.next();
System.out.printIn("請輸入會(huì)員積分:");
custNo = input.nextInt();
if(custNo1000||custNo9999){ //會(huì)員號無效則跳出
System.out.printIn("客戶號"+custNo+"是無效會(huì)員號!");
System.out.printIn("錄入信息失敗\n");
contiune;
}
System.out.printIn("您錄入的會(huì)員信息是:");
System.out.printIn(custNo+" "+birthday+" "+points+ "\n");
}
System.out.printIn("程序結(jié)束!");
}
}