| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1480 人关注过本帖
标题:刚学两个星期写的收银系统,完全是垃圾,大家帮忙解决几个问题
取消只看楼主 加入收藏
ykilsjj
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2008-7-25
收藏
 问题点数:0 回复次数:0 
刚学两个星期写的收银系统,完全是垃圾,大家帮忙解决几个问题
刚刚学了几个星期的java,还是十足的菜鸟,大家多多指导
当我编译后,前几遍正常,但当输入特别大的值后(物品单价),就会跳出中间的一个while循环,不执行while(finalpay<=sum)的判断,也就是当付款值小于结算金额的时候也直接执行finalpay-sum,最后找的钱是负数,但又找不到什么原因,大家帮帮忙啊
还有就是想找个师傅,能帮我学习java,然后我会学sql-sever,c#,没有报酬,有的只是尊敬与汲取o(∩_∩)o...
下面是代码
package second;
import java.util.*;
public class xfd {
    public static void main(String[] args) {
        double i = 1;
        while (i >= 1) {
            Scanner input = new Scanner(System.in);
            int username = 111;
            int password = 111;
            System.out.print("请输入管理员账号:");
            int username1 = input.nextInt();
            System.out.println("");
            System.out.print("请输入管理员密码:");
            int password1 = input.nextInt();
            if (username == username1 && password == password1) {
                System.out.println("进入收银管理系统,按0键退出,除0的任意键继续");
                int enter = input.nextInt();
                if (enter == 0) {
                    break;
                }
                int j = 1;
                while (j >= 1) {

                    /*
                     * }else if(username!=username1&&password==password1){
                     * System.out.println("账号错误,请从新输入"); }else if
                     * (username!=username1&&password!=password1){
                     * System.out.println("账号密码错误,请重新输入:"); }else
                     * if(username==username1&&password!=password1){
                     * System.out.println("密码错误,请从新输入:"); }
                     */

                    System.out.print("请输入T恤价格");
                    double shirtSpace = input.nextInt();
                    System.out.print("请输入网球鞋价格");
                    double shoeSpace = input.nextInt();
                    System.out.print("请输入球拍价格");
                    double padSpace = input.nextInt();
                    System.out.print("请输入T恤数量");
                    int shirtNo = input.nextInt();
                    System.out.print("请输入球鞋数量");
                    int shoeNo = input.nextInt();
                    System.out.print("请输入球拍数量");
                    int padNo = input.nextInt();
                    System.out.print("请输入付款总额");
                    short sum = (short) ((shirtSpace * shirtNo + shoeSpace* shoeNo + padSpace * padNo) * 0.8);
                    double finalPay = 0;
                    finalPay = input.nextInt();
                    while (finalPay <= sum) {

                        System.out.println("金额不足!请再加钱");
                        double finalpayadd = input.nextInt();
                        finalPay = finalPay + finalpayadd;
                    }
                    System.out
                            .println("****************消费单***************\n\n");
                    System.out.println("购买数量\t单价\t个数\t金额");
                    System.out.println("T恤\t¥" + shirtSpace + "\t" + shirtNo+ "\t" + shirtSpace * shirtNo);
                    System.out.println("网球鞋\t¥" + shoeSpace + "\t" + shoeNo+ "\t" + shoeSpace * shoeNo);
                    System.out.println("网球拍\t¥" + padSpace + "\t" + padNo    + "\t" + padSpace * padNo + "\n\n\n");
                    int discount = 8;
                    System.out.println("折扣:\t\t" + discount + "折");
                    System.out.println("金额总计:" + "\t¥" + sum);
                    System.out.println("实际交费:" + "\t¥" + finalPay);
                    double returnMoney = finalPay - sum;
                    System.out.println("找钱:\t" + "\t¥" + returnMoney);
                    int score = (int) sum / 100 * 3;
                    System.out.println("本次购物所获得的积分是:" + "\t" + score);
                    System.out.println("****************谢谢光临*************\n\n");
                    System.out.println("按0键退出.任意键再按确定继续");
                    enter = input.nextInt();
                    if (enter == 0) {
                        System.out.println("退出收银系统");
                    break;
                    }
                }
                break;
            } else {
                System.out.println("账号或密码错误,请从新输入");
            }
        }
    }
}
搜索更多相关主题的帖子: 垃圾 系统 收银 Scanner int 
2008-07-25 10:23
快速回复:刚学两个星期写的收银系统,完全是垃圾,大家帮忙解决几个问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.041491 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved