Assignemnt #103 and KeyChains For Sale, Real Ultimate Power

Code

    
    ///name: nick cerdan
    ///period: 6
    ///program name: Key Chains For Sale, RUP
    ///file name: KCFSRUP.java
    ///date finished: 11/30/15
    
    import java.util.Scanner;
            
            public class KCFSRUP
            {
                public static void main(String[] args)
                {
                    Scanner kb = new Scanner(System.in);
                    
                    int number, price, shippingorder, shippingper;
                    double stax;
                    
                    number = 0;
                    price = 10;
                    stax = 1.0825;
                    shippingorder = 5;
                    shippingper = 1;                
                    
                    System.out.println("The Kaychain shop");
                    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. Checkout");
                    System.out.println("");
                    System.out.print("Your Choice: ");
                    int choice = kb.nextInt();
                    System.out.println("");
                    
                    while (choice != 4)
                    {
                        if ( choice == 1)
                        {
                            number = addKeychains(number);
                        }
                        else if (choice == 2)
                            number = removeKeychains(number);
                        else if (choice == 3)
                            viewOrder(number, price, stax, shippingorder, shippingper);
                        else
                        {
                            System.out.println("ERROR: Please choose one of the options");
                        }
                        
                        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. Checkout");
                        System.out.println("");
                        System.out.print("Your Choice: ");
                        choice = kb.nextInt();
                        System.out.println("");
                    }
                    
                    checkout(number, price, stax, shippingorder, shippingper);
                }
                
                public static int addKeychains(int number)
                {
                    Scanner kb = new Scanner(System.in);
                    
                    int  total, add;
                    
                    System.out.print("You have " + number + " keychains. Add how many? ");
                    add = kb.nextInt();
                    
                    total = number + add;
                    
                    System.out.println("You now have " + total + " keychains");
                    
                    return total;
                }
                
                public static int removeKeychains(int number)
                {
                    Scanner kb = new Scanner(System.in);
                    
                    int total, take;
                    
                    total = 0;
                                    
                    System.out.print("You have " + number + " keychains. Remove how many? ");
                    take = kb.nextInt();
                    
                    total = number - take;
                    
                    while (total < 0)
                    {
                        System.out.println("You can't have less than 0 keychains.");
                        System.out.print("You have " + number + " keychains. Remove how many? ");
                        take = kb.nextInt();
                        
                        total = number - take;
                    }                
                    
                    System.out.println("You now have " + total + " keychains");
                    
                    return total;
                }
                
                public static void viewOrder(int number, int price, double stax, int shippingorder, int shippingper)
                {
                    int shiptotal = (number * shippingper) + shippingorder;
                    int subtotal = (number * price) + shiptotal;
                    double total = subtotal * stax;
                    
                    System.out.println("You currently have " + number + " keychains.");
                    System.out.println("Each keychain is $" + price + ".");
                    System.out.println("Your total shipping cost will be $" + shiptotal + ".");
                    System.out.println("Your subtotal is $" + subtotal + ".");
                    System.out.println("Your total cost is $" + total + ".");
                }
                
                public static void checkout(int number, int price, double stax, int shippingorder, int shippingper)
                {
                    Scanner kb = new Scanner(System.in); 
                    
                    System.out.print("What is you name? ");
                    String name = kb.next();
                    viewOrder(number, price, stax, shippingorder, shippingper);
                    System.out.println("Thank you for your order, " + name);
                }
            }   

    Assignment 103