Assignemnt #103 and Super Real Keychain Store

Code

    ///Name: Daniel Tiffany-Appleton
    ///Period: 7
    ///Program Name:  Super Real Keychain Store
    ///File Name: SuperRealKeychainStore
    ///Date Finished: 3/8/16
    
    import java.util.Scanner;
    
    public class SuperRealKeychainStore
    {
        public static void main( String args[] )
        {
            Scanner keyboard = new Scanner(System.in);
            int choice, keychains, baseShippingCost,  shippingCostPer;
            String name;
            double salesTax, cost;
            
            System.out.println("Ye Olde Keychain Shoppe");
            System.out.println(" ");
            choice = 0;
            keychains = 0;
            cost = 0;
            name = "bob";
            salesTax = 8.25/100;
            baseShippingCost = 5;
            shippingCostPer = keychains * 1;
            cost = keychains * 10;
            
            do 
            {
                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. Checkout");
                System.out.println(" ");
                System.out.print("Please enter your choice: ");
                choice = keyboard.nextInt();
                
                if( choice == 1 )
                {
                    keychains = addKeychains(keychains);
                    System.out.println("You now have " + keychains + " keychains.");
                    System.out.println(" ");
                }
                
                else if ( choice == 2 )
                {
                    keychains = removeKeychains(keychains);
                    System.out.println("You now have " + keychains + " keychains.");
                    System.out.println(" ");
                }
                
                else if ( choice == 3 )
                {
                    viewOrder(keychains, salesTax, cost, baseShippingCost, shippingCostPer);
                }
                
                else if ( choice == 4 )
                {
                    System.out.print("What is your name? ");
                    name = keyboard.next();
                    checkout(keychains, salesTax, cost, baseShippingCost, shippingCostPer);
                    System.out.println("Thanks for your order, " + name + "!");
                }
                
                else 
                {
                    System.out.println("ERROR! Not a choice.");
                    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. Checkout");
                    System.out.println(" ");
                    System.out.print("Please enter your choice: ");
                    choice = keyboard.nextInt();
                }
                
                cost = keychains * 10;
                
            }while( choice != 4 );
            
        }
        
        public static int addKeychains(int keychains)
        {
            Scanner keyboard = new Scanner(System.in);
            
            int add;
            
                System.out.println(" ");
                System.out.print("You have " + keychains + " keychains. How many to add? ");
                add = keyboard.nextInt();
                
                if(add < 0)
                {
                    while(add < 0)
                    {
                        System.out.print("ERROR! Number not positive, try again. ");
                        add = keyboard.nextInt();
                    }
                }
                
            keychains = keychains + add;
            
            return keychains;
        }
        
        public static int removeKeychains(int keychains)
        {
            Scanner keyboard = new Scanner(System.in);
            
            int subtract;
            System.out.println(" ");
            System.out.print("You have " + keychains + " keychains. How many to remove? ");
            subtract = keyboard.nextInt();
            keychains = keychains - subtract;
            
            return keychains;
        }
        
        public static void viewOrder(int keychains, double salesTax, double cost, int baseShippingCost, int shippingCostPer)
        {
            double tax, total;
            System.out.println(" ");
            System.out.println("You have " + keychains + " keychains.");
            System.out.println("Keychains cost $10 each.");
            System.out.println("Shipping cost per order is $5");
            
            total = cost + shippingCostPer + baseShippingCost;
            
            System.out.println("Pre-tax total cost is $" + total + ".");
            
            tax = total*salesTax;
            total = total + tax;
            
            System.out.println("Total tax is $" + tax + ".");
            System.out.println("Total cost is $" + total + ".");
            System.out.println(" ");
            
            return;
        }
        
        public static void checkout(int keychains, double salesTax, double cost, int baseShippingCost, int shippingCostPer)
        {
            double tax, total;
            System.out.println(" ");
            System.out.println("You have " + keychains + " keychains.");
            System.out.println("Keychains cost $10 each.");
            System.out.println("Shipping cost per order is $5");
            
            total = cost + shippingCostPer + baseShippingCost;
            
            System.out.println("Pre-tax total cost is $" + total + ".");
            
            tax = total*salesTax;
            total = total + tax;
            
            System.out.println("Total tax is $" + tax + ".");
            System.out.println("Total cost is $" + total + ".");
            System.out.println(" ");
            
            return;
        }
    }

    

Picture of the output

Assignment 103