Assignment #102 KeyChainsForReal

Code

    
    /// Name: Lacey Reese 
    /// Period: 5
    /// Program Name:  KeyChainsForReal
    /// File Name:  KeyChainsForReal.java
    /// Date Finished 3/31/2016
    
   
 import java.util.Scanner;
    
    public class KeyChainsForReal {
        
        public static void main( String[] args ) {
            
            Scanner keyboard = new Scanner(System.in);
            
            int choice = 1, numKeychains = 0, price = 10;
            
            System.out.println( "Lacey's Keychain Place" );
            System.out.println();
            
            while ( choice != 4 ) {
                
                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();
                System.out.println();
    
                if ( choice == 1 ) {
                    
                    numKeychains = addKeychains( numKeychains );
                    System.out.println( "You now have " + numKeychains + " keychains." );
                    
                } else if ( choice == 2 ) {
                    
                    numKeychains = removeKeychains( numKeychains );
                    System.out.println( "You now have " + numKeychains + " keychains." );
                    
                } else if ( choice == 3 ) {
                    
                    viewOrder( numKeychains, price );
                    
                } else if ( choice == 4 ) {
                    
                    checkout( numKeychains, price );
                    
                } else {
                    
                    System.out.println( "Please try again." );
                    
                }
                
                System.out.println();
            }
        }
        
        public static int addKeychains( int keychains ) {
            Scanner keyboard = new Scanner(System.in);
            System.out.print( "You have " + keychains + " keychains. How many to add? " );
            int add = keyboard.nextInt();
            keychains = keychains + add;
            return keychains;
        }
        
        public static int removeKeychains( int keychains ) {
            Scanner keyboard = new Scanner(System.in);
            System.out.print( "You have " + keychains + " keychains. How many to remove? " );
            int remove = keyboard.nextInt();
            keychains = keychains - remove;
            return keychains;
        }
        
        public static void viewOrder( int num, int cost ) {
            int total = num * cost;
            System.out.println( "You have " + num + " keychains." );
            System.out.println( "Keychains cost $" + cost + " each." );
            System.out.println( "Total cost is $" + total + "." );
        }
        
        public static void checkout( int num, int cost ) {
            Scanner keyboard = new Scanner(System.in);
            int total = num * cost;
            System.out.print( "What is your name? " );
            String name = keyboard.next();
            System.out.println( "You have " + num + " keychains." );
            System.out.println( "Keychains cost $" + cost + " each." );
            System.out.println( "Total cost is $" + total + "." );
            System.out.println( "Thanks for your order, " + name + "!" );
        }
    }


    

Picture of the output

Assignment 102