大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
package entity;
创新互联公司主要从事做网站、网站建设、网页设计、企业做网站、公司建网站等业务。立足成都服务新县,10多年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:18980820575
public class Market {
private int id;//id
private int num;//数量
private String goods;//商品
private double price;//价格
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("您消费共计:"+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("-------超市计价系统-------");
String goods1="可口可乐";
String goods2="爆米花";
String goods3="益达";
printTable("编号","商品","价格");
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("请输入商品的编号:");
int num = input.nextInt();
System.out.println("请输入商品的数量");
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");
}
}
//测试结果:
-------超市计价系统-------
编号 商品 价格
1 可口可乐 3.0¥
2 爆米花 5.0¥
3 益达 10.0¥
请输入商品的编号:
3
请输入商品的数量
5
您消费共计:50.0¥
算是最简单的吧
package cn.job01;
import java.util.Scanner;
public class Lx07 {
public static void choice() {
System.out.println("登陆菜单 ");
System.out.println("1登陆系统");
System.out.println("2退出");
}
static void choice1() {
System.out.println("购物管理系统客户信息");
System.out.println("1显示所有客户信息");
System.out.println("2添加客户信息");
System.out.println("3修改客户信息");
System.out.println("4查询客户信息");
}
static void choice2() {
System.out.println("购物管理系统真情回馈");
System.out.println("1幸运大放送");
System.out.println("2幸运抽奖");
System.out.println("3生日问候");
}
public static void main(String[] args) {
choice();
Scanner input = new Scanner(System.in);
System.out.println("请输入1or2");
int num = input.nextInt();
switch (num) {
case 1:
System.out.println("主菜单");
System.out.println("1客户信息管理");
System.out.println("2购物结算");
System.out.println("3真情回馈");
System.out.println("4注销");
break;
}
System.out.println("选择输入数字");
int num1 = input.nextInt();
switch (num1) {
case 1:
choice1();
break;
case 2:
System.out.println("购物结算");
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管理系统 客户信息管理 添加客户信息\n");
int custNo; //会员号
int birthday; //会员生日
int points = 0; //会员积分
Scanner input=new Scanner(System.in);
for(int i=0;i3;i++){ //循环录入会员信息
System.out.printIn("请输入会员号(4位整数):");
custNo = input.nextInt();
System.out.printIn("请输入会员生日(月\日用两位整数表示):");
custNo = input.next();
System.out.printIn("请输入会员积分:");
custNo = input.nextInt();
if(custNo1000||custNo9999){ //会员号无效则跳出
System.out.printIn("客户号"+custNo+"是无效会员号!");
System.out.printIn("录入信息失败\n");
contiune;
}
System.out.printIn("您录入的会员信息是:");
System.out.printIn(custNo+" "+birthday+" "+points+ "\n");
}
System.out.printIn("程序结束!");
}
}
if (("+-*/".indexOf(conn)) != -1) {
if("".equals(d_one) "".equals(jtx.getText())) return;
d_one = jtx.getText();
operator = conn;
jtx.setText("");
return;
}
import java.util.Scanner; public class ChangeGoods { public static void main(String[] args) { System.out.println("输入消费金额:"); Scanner scanner = new Scanner(System.in); String money = scanner.next(); int spendMoney = Integer.parseInt(money); System.out.println( "是否参加优惠换购活动?\n" + "1:满50元,加2元换购百事可乐饮料1瓶\n" + "2:满100元,加3元换购500ml可乐一瓶\n" + "3:满100元,加10元换购5公斤面粉\n" + "4:满200元,加10元可换购1个苏泊尔炒菜锅\n" + "5:满200元,加20元可换购欧莱雅爽肤水一瓶\n" + "0:不换购\n" + "请选择:" ); Scanner scannerInput = new Scanner(System.in); String select = scanner.next(); int option = Integer.parseInt(select); switch (option) { case 0: System.out.println("本次消费总金额:" + money); break; case 1: if(spendMoney=50){ System.out.println("本次消费总金额:" + (spendMoney + 2) ); System.out.println("成功换购:百事可乐饮料1瓶"); } break; case 2: if(spendMoney=100){ System.out.println("本次消费总金额:" + (spendMoney + 3) ); System.out.println("成功换购:500ml可乐一瓶"); } break; case 3: if(spendMoney=100){ System.out.println("本次消费总金额:" + (spendMoney + 10) ); System.out.println("成功换购:5公斤面粉"); } break; case 4: if(spendMoney=200){ System.out.println("本次消费总金额:" + (spendMoney + 10) ); System.out.println("成功换购:1个苏泊尔炒菜锅"); } break; case 5: if(spendMoney=200){ System.out.println("本次消费总金额:" + (spendMoney + 20) ); System.out.println("成功换购:欧莱雅爽肤水一瓶"); } break; default: break; } } }