Assignemnt #99 Keychain Store Ultimate!!

Code

 /// Name: JJ Deng
    /// Period: 6
    /// Program Name: Chains For Real Ult
    /// File Name: ChainsUlt.java
    /// Date Finished: 3/28/2016
    
    import java.util.Scanner;
import java.util.InputMismatchException;

public class ChainsUlt{
    static Scanner keyboard = new Scanner(System.in);
    static int currentKey = 0;
    static float tax = 0.0825f;
    static int shipping = 5;
    static int shippingperKey = 1;
    static int price = 7;
    public static void main(String[] args){
        System.out.println("WELCOME");
        
        int choice = 0;
        
        do{
            showMenu();
            
            do choice = choice();
            while (choice ==0);
            
            if (choice == 1) addKey();
            if ( choice == 2) removeKey();
            if (choice == 3) viewOrder();
            
        }
        while (choice!=4);
        
        checkOut();
        
        System.out.println();
    }
    
    public static void showMenu(){
        System.out.println("");
        System.out.println("1) Add Keychains to Order");
        System.out.println("2) Remove Keychains from Order");
        System.out.println("3) View Current Order");
        System.out.println("4) Check Out");
        System.out.println("");
    }
    
    public static int choice() {
        int choice = 0;
        System.out.print("Choice: ");
        choice = keyboard.nextInt();
                System.out.println();

        
        if (choice < 1 || choice > 4) choice = 0;
        
        return choice;
    }
    
    public static void addKey(){
        System.out.print("How many?: ");
        try{
            int add = keyboard.nextInt();
            if ( add>0)
            {
             currentKey += add;
                System.out.println();
             System.out.println(add + " KEYCHAIN ADDED");
            System.out.println("");
                Chains();
            }
            else System.out.println("ERROR");
        }
        catch (InputMismatchException e)
        {
            System.out.println("ERROR");
        }
        
        
        
        
    }
    
    public static void removeKey(){
        System.out.print("How many?: ");
        try {
            int del = keyboard.nextInt();
            if ( del > 0 && del <= currentKey){
                currentKey -= del;
                System.out.println();
                System.out.println(del + " KEYCHAIN REMOVED");
                System.out.println("***********************");
                Chains();
            }
            else System.out.println("ERROR");
        }
        catch (InputMismatchException e){
            System.out.println("ERROR");
        }

        
    
    }
    public static void viewOrder(){
        System.out.println();
        int cost = (price*currentKey+(shipping + currentKey*shippingperKey));
        Chains();
        System.out.println("$7 per Keychains.");
        System.out.println("");
        System.out.println("Price: $"+(price*currentKey)+".");
        System.out.println("Shipping fee: $"+(shipping+currentKey*shippingperKey)+".");
        System.out.println("Price + shipping fee: $"+cost+".");
        double pTax = (0.0825*(price*currentKey+(shipping + currentKey*shippingperKey)));
        System.out.println("Tax: $"+pTax+".");
        System.out.println("");
        System.out.println("TOTAL COST:$"+cost*(1+tax)+".");
    }
    
    
    public static void checkOut(){
        System.out.print("What is your name? ");
        String name = keyboard.next();
        Chains();
        System.out.println("Keychains cost $7 each.");
        int cost = (price*currentKey);
        System.out.println("Total cost is $"+cost);
        System.out.println("Thanks for your order, "+name+" !");
    
        
        
        
    }
    
    public static void Chains() {
        
        System.out.println("YOU HAVE "+currentKey+" KEYCHAINS.");
    }
}



    

Picture of the output

Assignment 103