15.3.3
来源:互联网 发布:大数据的利用过程顺序 编辑:程序博客网 时间:2024/05/16 19:54
<span style="font-size:24px;">import java.util.*;public class sfdsd {String[] goods = new String[] { "电风扇", "洗衣机", "电视机", "冰箱", "空调机" };double[] price = new double[] { 124.23, 4500, 8800.90, 5000.88, 4456 };double total;public boolean login() {boolean flag = false;Scanner input = new Scanner(System.in);System.out.print(" 请输入用户名: ");String name = input.next();System.out.print(" 请输入密码: ");String pwd = input.next();if (name.equals("Tom") && pwd.equals("123")) {System.out.println("登录成功");flag = true;}return flag;}public StringBuffer change(double d) {StringBuffer str = new StringBuffer(String.valueOf(d));for (int i = str.indexOf(".") - 3; i > 0; i = i - 3) {str.insert(i, ',');}return str;}public void show() {Scanner input = new Scanner(System.in);System.out.println("*********欢迎进入商品批发城*********");System.out.println("\t编号\t商品\t价格");for (int i = 0; i < goods.length; i++) {System.out.println("\t" + (i + 1) + "\t" + goods[i] + "\t"+ change(price[i]));}System.out.println("************************************");System.out.print("请输入您批发的商品编号: ");int choice = input.nextInt();System.out.print("请输入批发数量: ");int number = input.nextInt();switch (choice) {case 1:total = price[0] * number;break;case 2:total = price[1] * number;break;case 3:total = price[2] * number;break;case 4:total = price[3] * number;break;case 5:total = price[4] * number;break;}System.out.println("您需要付款:" + change(total));}public static void main(String[] args) {sfdsd g = new sfdsd();if (g.login()) {g.show();} else {System.out.println("退出");}}}</span>
0 0
- 15.3.3
- 2013-3-15.3
- 算法导论 练习题 15.3-3
- 15.3
- 15.3.3 将函数转换成“行为函数”
- (二)struts2- 2.3.15.3 spring3.2.4 mybatis-3.2.3 集成jquery-ui-1.10.3
- 15.3.1
- 15.3Sum
- 15.3Sum
- 15.3sum
- 15.3Sum
- 15.3Sum
- 15.3Sum
- 15.3Sum
- 15.3 Sum
- 15.3Sum
- Thinking in C++读书笔记--15.3.3模板中的常量
- 算法导论第15章习题15.3-3最大矩阵链乘法
- 关于python编译时出现的问题
- webStorm 注册码
- 【数据结构】(1)顺序表
- ES6中的变量解构赋值的书写模式
- FusionChart 复杂类型图表
- 15.3.3
- 15章字符串上机2,3,4
- 15章 上机4
- MAC上卸载Jenkins的方法
- FreeMarker(FTL)简单介绍
- java文本转语音
- Swift:邮箱网址手机号码等正则判断
- CSS3第一节
- Java 实现会员注册升级 关键代码