Untitled

mail@pastecode.io avatar
unknown
java
2 years ago
3.2 kB
2
Indexable
Never
import java.util.Scanner;

class _A_DATATYPE {
    public int _1_greenbamboo_money = 6, _1_bluebamboo_money = 8, _1_purplebamboo = 10;

    public int greenbamboo, bluebamboo, purplebamboo;

    public String discountcode;
    public String decision;

    public double usermoneynumber;

    public boolean yn_check = true;
}

class test {

    public static void main(String[] args) {

        _A_DATATYPE ADT = new _A_DATATYPE();
        Scanner input = new Scanner(System.in);

        System.out.print("請輸入綠色籤子的數目 :");
        ADT.greenbamboo = input.nextInt();

        System.out.print("請輸入藍色籤子的數目 :");
        ADT.bluebamboo = input.nextInt();

        System.out.print("請輸入紫色籤子的數目 :");
        ADT.purplebamboo = input.nextInt();

        System.out.println("\n-----已點選清單-----");

        int greencount = ADT._1_greenbamboo_money * ADT.greenbamboo;
        int bluecount = ADT._1_bluebamboo_money * ADT.bluebamboo;
        int purplecount = ADT._1_purplebamboo * ADT.purplebamboo;

        int gbp_幾多枝 = ADT.greenbamboo + ADT.bluebamboo + ADT.purplebamboo;

        System.out.println("綠色籤 ($6) x " + ADT.greenbamboo + "枝,共$" + greencount);
        System.out.println("藍色籤 ($8) x " + ADT.bluebamboo + "枝,共$" + bluecount);
        System.out.println("紫色籤 ($10) x " + ADT.purplebamboo + "枝,共$" + purplecount);
        System.out.println("----------------\n");

        double _nondiscount = greencount + bluecount + purplecount;
        System.out.println("折扣前$: " + _nondiscount);

        System.out.println("請問你要輸入折扣碼嗎?[Y/N]");
        ADT.decision = input.next();
        
        if (ADT.decision.equals("Y")) 
        {
            System.out.print("請輸入你的優惠碼 :");
            ADT.discountcode = input.next();
            while(ADT.yn_check)
            {
                if (ADT.discountcode.equals("USETHIS")) 
                {
                    System.out.print("成功使用優惠碼 !\n");
                    break;
                } 
                else 
                {
                    System.out.print("優惠碼無效,請再次輸入 : ");
                    ADT.discountcode = input.next();
                }
            }
            if(gbp_幾多枝 ==6)
            {
                System.out.print("已享用折扣:買滿"+ADT.greenbamboo+"串"+"免收\n\n");
            }
        }
        else if (ADT.decision.equals("N")) 
        {
            System.out.println("唔撚用Discount Code");
        } 
        else 
        {
            System.out.print("請輸入 Y 或者 N : ");
            ADT.discountcode = input.next();
        }

        double all_money = ADT.usermoneynumber - _nondiscount;

        System.out.print("請輸入食客給予的銀碼($): ");
        ADT.usermoneynumber = input.nextDouble();

        if(ADT.usermoneynumber <_nondiscount)
            System.out.print("你俾唔夠錢 係咪玩野?");

        else if(ADT.usermoneynumber >= _nondiscount)
        {
            System.out.print("收: "+ADT.usermoneynumber+"\t"+"找: "+ all_money);
        }

        input.close();
    }
}