Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: Parameter's value is never changing

  1. #1
    Java kindergarten chronoz13's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    659
    Thanks
    177
    Thanked 30 Times in 28 Posts

    Default Parameter's value is never changing

    ill post my code first

    my method :
      public void setOrder(int numberOfOrders, Long contractNumber, String clientName) throws IOException {
     
     
            this.numberOfOrders = numberOfOrders;
            this.contractNumber = contractNumber;
            this.clientName = clientName;
     
            /**
             * if the number of order is too small and it's not even enough to fit a
             * small box then do this
             */
            if (numberOfOrders < 5) {
     
                if (numberOfOrders <= 0) {
     
                    /**
                     * if the number of orders is 0 or negative then the whole
                     * program will terminate
                     */
                    System.out.print("\n");
                    System.out.println("Invalid Order.");
                    System.out.println("System Will Exit.");
                    System.exit(0);
                }
                else {
     
                    do {
     
                        System.out.print("\n");
                        System.out.println("Cannot Include To Shipment That Is Less Than 5 Orders.");
                        System.out.println("Invalid Order.");
     
                        orderAgain = reOrder();
                    }
                    while (orderAgain == true && this.numberOfOrders > 5);
     
                    if (orderAgain == false) {
     
                        System.out.print("\n");
                        System.out.println("Thank You. Come Again!");
                    }
                }
            }
     
            /** check if the number of orders is less than 20 but greater than or equal to 5 */
            if ((this.numberOfOrders < 20) && (this.numberOfOrders >= 5)) {
     
                do {
     
                    System.out.print("\n");
                    System.out.println("Your Order Is Too Small");
     
                    if (this.numberOfOrders == 5) {
     
                        singleSmallBoxOrderCount = this.numberOfOrders;
                        smallBoxCount++;
     
                        /** sets the cost of the bags in a single small box */
                        singleSmallBoxCostPerBag = this.numberOfOrders * COFFEE_BAG_PRICE;
                    }      
                    else if (this.numberOfOrders < 10) {
     
                        /** temporary count for the number of orders */
                        tempCount = this.numberOfOrders;
                        firstSmallBoxOrderCount = 5;
     
                        /** do the count f the small box that will be used and the excess */
                        for (orderCount = this.numberOfOrders; orderCount >= 5; orderCount = orderCount - 5){
     
                            smallBoxCount++;
                            excess = orderCount - 5;
     
                        }
     
                        /** this will make the count for the bags in the first small box */
                        tempCount = tempCount - excess;
     
                        /** sets the cost of the bags in the first small box */
                        firstSmallBoxCostPerBag = tempCount * COFFEE_BAG_PRICE;       
     
                        if ((excess < 5) && (excess != 0)) {
     
                            remSmallBoxOrderCount = excess;
                            smallBoxCount++;
     
                            /** sets the cost of the bags in the remaining small box */
                            remSmallBoxCostPerBag = excess * COFFEE_BAG_PRICE;
                        }
                    }
                    /**
                     * if number of orders is less than 20 (i.e 19 below) then do this
                     */
                    else if (this.numberOfOrders < 20) {
     
                        /** temporary count for the number of orders that is less than 20 */
                        tempCount = this.numberOfOrders;
     
                        mediumBoxOrderCount = 10;
     
                        /** do the count for the medium box that will be used and for the excess of medium box*/
                        for (orderCount = this.numberOfOrders; orderCount >= 10; orderCount = orderCount - 10) {
     
                            mediumBoxCount++;
                            excess = orderCount - 10;                                      
                        }
     
                        /** this will make the count for the bags in the medium box */
                        tempCount = tempCount - excess;
     
                        /** sets the cost of the coffee bags inside the medium box */
                        mediumBoxCostPerBag = tempCount * COFFEE_BAG_PRICE;                   
     
                        /** if the excess is exactly 5 or less, then do this */
                        if ((excess <= 5) && (excess != 0)){
     
                            /**
                             * this will hold the value if the excess order is for a single small box only
                             */
                            singleSmallBoxOrderCount = excess;
     
                            smallBoxCount++;
     
                            /** sets the cost of the coffee bags insisde the single small box */
                            singleSmallBoxCostPerBag = excess * COFFEE_BAG_PRICE;
                        }
                        /**
                         * check if the excess is greater than or equal to five and good for
                         * two small boxes
                         */
                        else if (excess >= 5) {
     
                            /** 
                             * temporary count for the excess that is greater than
                             * or equal to 5
                             */
                            tempCount = excess;
     
                            /**
                             * this will set the first 5 bags of the excess order into a
                             * small box
                             */
                            firstSmallBoxOrderCount = 5;
     
                            /** do the count for the small box that will be used and for the excess */
                            for (orderCount = excess; orderCount >= 5; orderCount = orderCount - 5) {
     
                                smallBoxCount++;
                                excess = orderCount - 5;                    
                            }
     
                            /** this will make the count for the bags inside the first small box */
                            tempCount = tempCount - excess;
     
                            /** sets the cost of the bags inside the first small box */
                            firstSmallBoxCostPerBag = tempCount * COFFEE_BAG_PRICE;
     
                            if ((excess < 5) && (excess != 0)) {
     
                                /**
                                 * this will hold the value of the remaining excess order
                                 */
                                remSmallBoxOrderCount = excess;
                                smallBoxCount++;
     
                                /** sets the cost of the bags in the remaining small box */
                                remSmallBoxCostPerBag = excess * COFFEE_BAG_PRICE;
                            }
                        }
                    }
     
                    orderAgain = reOrder();
     
                    System.out.print(numberOfOrders);
                }
                while ((orderAgain == true) && (numberOfOrders < 20));    //this part..
    the reOrder method();
       private boolean reOrder() throws IOException {
     
             String reOrder;
     
             System.out.print("\n");
             System.out.print("Do You Want To Order Again?: ");
             reOrder = br.readLine();
     
             if ((reOrder.equalsIgnoreCase("Y")) || (reOrder.equalsIgnoreCase("YES"))) {
     
                 mediumBoxCount = 0;
                 smallBoxCount = 0;
                 excess = 0;
                 numberOfOrders = 0;
                 orderCount = 0;
                 firstSmallBoxOrderCount = 0;
                 remSmallBoxOrderCount = 0;
                 singleSmallBoxOrderCount = 0;
                 mediumBoxOrderCount = 0;
     
                 System.out.print("\n");
                 System.out.print("Enter Your New Order: ");
                 numberOfOrders = Integer.parseInt(br.readLine());
     
                 setOrder(numberOfOrders, contractNumber, clientName);
     
                 return true;
             }
             else if ((reOrder.equalsIgnoreCase("N")) || (reOrder.equalsIgnoreCase("NO"))) {
     
                 return false;
             }
             else {
     
                 return false;
             }
         }




    and the main program that uses this two

    public class CoffeeBeansShipment {
     
        private static BufferedReader br = new BufferedReader(new InputStreamReader(
                                           System.in));
     
        public static void main(String[] args) throws IOException {
     
            CoffeBeans_FINALCLASS_UF_TEMP coffee = new CoffeBeans_FINALCLASS_UF_TEMP();
     
            int numberOfOrders;
            int shipmentCount = 0;
            long contractNumber;
     
            String clientName;
     
            do {
     
                System.out.print("Enter The Number Of Orders: ");
                numberOfOrders = Integer.parseInt(br.readLine());
     
                contractNumber = (int) (Math.ceil(Math.random() * 10000000));
     
                System.out.print("\n");
                System.out.print("Enter The Client's Name: ");
                clientName = br.readLine();
     
                do {
     
                    if (clientName.equals("")) {
     
                        System.out.print("\n");
                        System.out.println("You Didnt Enter A Valid Name!");
                        System.out.print("Enter The Client's Name: ");
                        clientName = br.readLine();
                    }
                }
                while (clientName.equals(""));
     
                coffee.setOrder(numberOfOrders, contractNumber, clientName);
                coffee.showOrder();
            }
            while (coffee.nextOrder());


    for me to clear it out ... follow this

    1.) run the main program... enter number 10. for the number of orders,
    2.) it will recieve by the setOrder()'s parameter ..
    3.) it will check the numeber of orders..
    4.) we entered '10' so one of the if blocks will be executed


    im having problem with the loop part....
                do {
     
                    System.out.print("\n");
                    System.out.println("Your Order Is Too Small");
     
                    if (this.numberOfOrders == 5) {
     
                        singleSmallBoxOrderCount = this.numberOfOrders;
                        smallBoxCount++;
     
                        /** sets the cost of the bags in a single small box */
                        singleSmallBoxCostPerBag = this.numberOfOrders * COFFEE_BAG_PRICE;
                    }      
                    else if (this.numberOfOrders < 10) {
     
                        /** temporary count for the number of orders */
                        tempCount = this.numberOfOrders;
                        firstSmallBoxOrderCount = 5;
     
                        /** do the count f the small box that will be used and the excess */
                        for (orderCount = this.numberOfOrders; orderCount >= 5; orderCount = orderCount - 5){
     
                            smallBoxCount++;
                            excess = orderCount - 5;
     
                        }
     
                        /** this will make the count for the bags in the first small box */
                        tempCount = tempCount - excess;
     
                        /** sets the cost of the bags in the first small box */
                        firstSmallBoxCostPerBag = tempCount * COFFEE_BAG_PRICE;       
     
                        if ((excess < 5) && (excess != 0)) {
     
                            remSmallBoxOrderCount = excess;
                            smallBoxCount++;
     
                            /** sets the cost of the bags in the remaining small box */
                            remSmallBoxCostPerBag = excess * COFFEE_BAG_PRICE;
                        }
                    }
                    /**
                     * if number of orders is less than 20 (i.e 19 below) then do this
                     */
                    else if (this.numberOfOrders < 20) {
     
                        /** temporary count for the number of orders that is less than 20 */
                        tempCount = this.numberOfOrders;
     
                        mediumBoxOrderCount = 10;
     
                        /** do the count for the medium box that will be used and for the excess of medium box*/
                        for (orderCount = this.numberOfOrders; orderCount >= 10; orderCount = orderCount - 10) {
     
                            mediumBoxCount++;
                            excess = orderCount - 10;                                      
                        }
     
                        /** this will make the count for the bags in the medium box */
                        tempCount = tempCount - excess;
     
                        /** sets the cost of the coffee bags inside the medium box */
                        mediumBoxCostPerBag = tempCount * COFFEE_BAG_PRICE;                   
     
                        /** if the excess is exactly 5 or less, then do this */
                        if ((excess <= 5) && (excess != 0)){
     
                            /**
                             * this will hold the value if the excess order is for a single small box only
                             */
                            singleSmallBoxOrderCount = excess;
     
                            smallBoxCount++;
     
                            /** sets the cost of the coffee bags insisde the single small box */
                            singleSmallBoxCostPerBag = excess * COFFEE_BAG_PRICE;
                        }
                        /**
                         * check if the excess is greater than or equal to five and good for
                         * two small boxes
                         */
                        else if (excess >= 5) {
     
                            /** 
                             * temporary count for the excess that is greater than
                             * or equal to 5
                             */
                            tempCount = excess;
     
                            /**
                             * this will set the first 5 bags of the excess order into a
                             * small box
                             */
                            firstSmallBoxOrderCount = 5;
     
                            /** do the count for the small box that will be used and for the excess */
                            for (orderCount = excess; orderCount >= 5; orderCount = orderCount - 5) {
     
                                smallBoxCount++;
                                excess = orderCount - 5;                    
                            }
     
                            /** this will make the count for the bags inside the first small box */
                            tempCount = tempCount - excess;
     
                            /** sets the cost of the bags inside the first small box */
                            firstSmallBoxCostPerBag = tempCount * COFFEE_BAG_PRICE;
     
                            if ((excess < 5) && (excess != 0)) {
     
                                /**
                                 * this will hold the value of the remaining excess order
                                 */
                                remSmallBoxOrderCount = excess;
                                smallBoxCount++;
     
                                /** sets the cost of the bags in the remaining small box */
                                remSmallBoxCostPerBag = excess * COFFEE_BAG_PRICE;
                            }
                        }
                    }
     
                    orderAgain = reOrder();
     
                    System.out.print(numberOfOrders);
                }
                while ((orderAgain == true) && (numberOfOrders < 20));    //this part..
    why is the numberOfOrders(which is the parameter) never changes the value?


    when im actually entering a new value in the reOrder() method that will be passed again in the setOrder()'s parameter?
    the loop is looping for ever...


    i cant understand the flow....
    the sequence..... IM CHANGEING THE VALUE OF the field(numberOfOrders) but the parameters of the setOrder() method is not changing in anyways... please help!

    is it the value of number of orders in MY MAIN PROGRAM???? thats why the value of setOrder()'s parameter
    is not changing?

    ill post the whole CLASS code for you to see the problem...


    package xTestsx;
     
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.text.DecimalFormat;
     
    /**
     * class used for a coffee beans order that will be included in a shipment
     *
     * @author  JSoft
     *
     * @see     CoffeeBeansShipment.java in preDefinedClassesApplications package
     */
     
    public class CoffeBeans_FINALCLASS_UF_CC {
     
        private static DecimalFormat df = new DecimalFormat("0.00");
     
        private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
     
        /** constant coffee bag price */
        private static final double COFFEE_BAG_PRICE = 5.50;
     
        /** constant large box price */
        private static final double LARGE_BOX_PRICE = 1.80;
     
        /** constant medium box price */
        private static final double MEDIUM_BOX_PRICE = 1.00;
     
        /** constant small box price */
        private static final double SMALL_BOX_PRICE = 0.60;
     
        /** 
         * this will hold the return value of the reOrder() method to check if the user
         * wants to re-order again
         */
        private boolean orderAgain;
     
        /** this will be used for some temporary counts */
        private int tempCount;
     
        /** total count of how many times the valid order has been done */
        private int totalOrderCount;
     
        /** number of orders */
        private int numberOfOrders;
     
        /** this will determine the total number of orders in the whole shipment */
        private int totalNumberOfOrders;
     
        /**
         * the number of large box that will be used
         */
        private int largeBoxCount;
     
        /**
         * the number of medium box that will be used
         */
        private int mediumBoxCount;
     
        /**
         * the number of small box that will be used
         */
        private int smallBoxCount;
     
        /**
         * the number of order that will be counted to assign each order in their
         * corresponding size of box
         */
        private int orderCount;
     
        /**
         * this will hold the number of orders in each large box
         */
        private int largeBoxOrderCount;
     
        /**
         * this will hold the number of orders in each medium box
         */
        private int mediumBoxOrderCount;
     
        /**
         * this will hold the number of orders in a small box if the
         * small box that will be used is more than 1
         */
        private int firstSmallBoxOrderCount;
     
        /**
         * this will hold the remaining number of orders after assigning the first 5
         * orders in the first small box
         */
        private int remSmallBoxOrderCount;
     
        /**
         * if the small box that will be used is only 1, then the number of order will
         * be assgined in this single small box
         */   
        private int singleSmallBoxOrderCount;
     
        /**
         * this will hold the excess number of orders
         */
        private int excess;
     
        /**
         * this will hold the total count of all the boxes that was used per order
         */
        private int totalBoxesPerOrder;
     
        /** total count of the large box in the whole shipment */
        private int totalLargeBox;
     
        /** total count of the medium box in the whole shipment */
        private int totalMediumBox;
     
        /** total count of the small box in the whole shipment */
        private int totalSmallBox;
     
        /** total count of the boxes int the shipment */
        private int totalBoxesInShipment;
     
        /** contract number of the corresponding customer */
        private long contractNumber;
     
        /** total cost of the coffee beans bags that will be assigned in a large box */
        private double largeBoxCostPerBag;
     
        /** total cost of the coffee beans bags that will be assigned in a medium box */
        private double mediumBoxCostPerBag;
     
        /**
         * total cost of the coffee beans bags that will be assigned in the first
         * small box that will be used
         */
        private double firstSmallBoxCostPerBag;
     
        /**
         * total cost of the remaining coffee beans bags that will be assigned in the
         * remaining small box that will be used
         */
        private double remSmallBoxCostPerBag;
     
        /** total cost of the coffee beans bags that will be assgined in a single small box */
        private double singleSmallBoxCostPerBag;
     
        /** total cost of the large boxes that have been used per order */
        private double totalLargeBoxCostPerOrder;
     
        /** total cost of the medium boxes that have been used per order */
        private double totalMediumBoxCostPerOrder;
     
        /** total cost of the small boxes that have been used per order*/
        private double totalSmallBoxCostPerOrder;
     
        /** total Cost of the boxes that were used per order*/
        private double totalBoxesCostPerOrder;
     
        /** cost of each order */
        private double totalOrderCostPerOrder;
     
        /** shipment cost per order */
        private double shipmentCostPerOrder;
     
        /** this will determine the total cost of the whole shipment */
        private double totalShipmentCost;
     
        /** total cost of the large box that was used in the whole shipment */
        private double totalLargeBoxCost;
     
        /** total cost of the medium box that was used in the whole shipment */
        private double totalMediumBoxCost;
     
        /** total cost of the small box that was used in the whole shipment */
        private double totalSmallBoxCost;
     
        /** total cost of the coffee beans that was ordered in the whole shipment */
        private double totalCoffeeBeansCost;
     
        /** custormer name */
        private String clientName;
     
        /**
         * this will be the placeholder of the string value that will be returned by the
         * includeToShipment() method
         */
        private String includeOrder;
     
        public CoffeBeans_FINALCLASS_UF_CC() {
     
            this.orderAgain = false;
            this.totalOrderCount = 0;
            this.tempCount = 0;
            this.numberOfOrders = 0;
            this.largeBoxCount = 0;
            this.mediumBoxCount = 0;
            this.smallBoxCount = 0;
            this.orderCount = 0;
            this.largeBoxOrderCount = 0;
            this.mediumBoxOrderCount = 0;
            this.firstSmallBoxOrderCount = 0;
            this.remSmallBoxOrderCount = 0;
            this.singleSmallBoxOrderCount = 0;
            this.excess = 0;    
            this.totalBoxesPerOrder = 0;
            this.totalLargeBox = 0;
            this.totalMediumBox = 0;
            this.totalSmallBox = 0;
            this.totalBoxesInShipment = 0;
            this.contractNumber = 0L;
            this.shipmentCostPerOrder = 0.0;
            this.totalOrderCostPerOrder = 0.0;
            this.largeBoxCostPerBag = 0.0;
            this.mediumBoxCostPerBag = 0.0;
            this.firstSmallBoxCostPerBag = 0.0;
            this.remSmallBoxCostPerBag = 0.0;
            this.singleSmallBoxCostPerBag = 0.0;
            this.totalLargeBoxCostPerOrder = 0.0;
            this.totalMediumBoxCostPerOrder = 0.0;
            this.totalSmallBoxCostPerOrder = 0.0;
            this.totalBoxesCostPerOrder = 0.0;
            this.totalShipmentCost = 0.0;
            this.totalLargeBoxCost = 0.0;
            this.totalMediumBoxCost = 0.0;
            this.totalSmallBoxCost = 0.0;
            this.totalCoffeeBeansCost = 0.0;
            this.totalNumberOfOrders = 0;
            this.clientName = "";
            this.includeOrder = "";
        }
     
        /**
         * @param   numberOfOrders to be computed in a shipment
         * @param   contractNumber 
         * @param   customerName
         * @throws  IOException 
         */
        public void setOrder(int numberOfOrders, Long contractNumber, String clientName) throws IOException {
     
            this.numberOfOrders = numberOfOrders;
            this.contractNumber = contractNumber;
            this.clientName = clientName;
     
            /**
             * if the number of order is too small and it's not even enough to fit a
             * small box then do this
             */
            if (this.numberOfOrders < 5) {
     
                if (this.numberOfOrders <= 0) {
     
                    /**
                     * if the number of orders is 0 or negative then the whole
                     * program will terminate
                     */
                    System.out.print("\n");
                    System.out.println("Invalid Order.");
                    System.out.println("System Will Exit.");
                    System.exit(0);
                }
                else {
     
                    do {
     
                        System.out.print("\n");
                        System.out.println("Cannot Include To Shipment That Is Less Than 5 Orders.");
                        System.out.println("Invalid Order.");
     
                        orderAgain = reOrder();
                    }
                    while (orderAgain == true && this.numberOfOrders < 5);
     
                    if (orderAgain == false) {
     
                        System.out.print("\n");
                        System.out.println("Thank You. Come Again!");
                    }
                }
            }
     
            /** check if the number of orders is less than 20 but greater than or equal to 5 */
            if ((this.numberOfOrders < 20) && (this.numberOfOrders >= 5)) {
     
                do {
     
                    System.out.print("\n");
                    System.out.println("Your Order Is Too Small");
     
                    if (this.numberOfOrders == 5) {
     
                        singleSmallBoxOrderCount = this.numberOfOrders;
                        smallBoxCount++;
     
                        /** sets the cost of the bags in a single small box */
                        singleSmallBoxCostPerBag = this.numberOfOrders * COFFEE_BAG_PRICE;
                    }      
                    else if (this.numberOfOrders < 10) {
     
                        /** temporary count for the number of orders */
                        tempCount = this.numberOfOrders;
                        firstSmallBoxOrderCount = 5;
     
                        /** do the count f the small box that will be used and the excess */
                        for (orderCount = this.numberOfOrders; orderCount >= 5; orderCount = orderCount - 5){
     
                            smallBoxCount++;
                            excess = orderCount - 5;
     
                        }
     
                        /** this will make the count for the bags in the first small box */
                        tempCount = tempCount - excess;
     
                        /** sets the cost of the bags in the first small box */
                        firstSmallBoxCostPerBag = tempCount * COFFEE_BAG_PRICE;       
     
                        if ((excess < 5) && (excess != 0)) {
     
                            remSmallBoxOrderCount = excess;
                            smallBoxCount++;
     
                            /** sets the cost of the bags in the remaining small box */
                            remSmallBoxCostPerBag = excess * COFFEE_BAG_PRICE;
                        }
                    }
                    /**
                     * if number of orders is less than 20 (i.e 19 below) then do this
                     */
                    else if (this.numberOfOrders < 20) {
     
                        /** temporary count for the number of orders that is less than 20 */
                        tempCount = this.numberOfOrders;
     
                        mediumBoxOrderCount = 10;
     
                        /** do the count for the medium box that will be used and for the excess of medium box*/
                        for (orderCount = this.numberOfOrders; orderCount >= 10; orderCount = orderCount - 10) {
     
                            mediumBoxCount++;
                            excess = orderCount - 10;                                      
                        }
     
                        /** this will make the count for the bags in the medium box */
                        tempCount = tempCount - excess;
     
                        /** sets the cost of the coffee bags inside the medium box */
                        mediumBoxCostPerBag = tempCount * COFFEE_BAG_PRICE;                   
     
                        /** if the excess is exactly 5 or less, then do this */
                        if ((excess <= 5) && (excess != 0)){
     
                            /**
                             * this will hold the value if the excess order is for a single small box only
                             */
                            singleSmallBoxOrderCount = excess;
     
                            smallBoxCount++;
     
                            /** sets the cost of the coffee bags insisde the single small box */
                            singleSmallBoxCostPerBag = excess * COFFEE_BAG_PRICE;
                        }
                        /**
                         * check if the excess is greater than or equal to five and good for
                         * two small boxes
                         */
                        else if (excess >= 5) {
     
                            /** 
                             * temporary count for the excess that is greater than
                             * or equal to 5
                             */
                            tempCount = excess;
     
                            /**
                             * this will set the first 5 bags of the excess order into a
                             * small box
                             */
                            firstSmallBoxOrderCount = 5;
     
                            /** do the count for the small box that will be used and for the excess */
                            for (orderCount = excess; orderCount >= 5; orderCount = orderCount - 5) {
     
                                smallBoxCount++;
                                excess = orderCount - 5;                    
                            }
     
                            /** this will make the count for the bags inside the first small box */
                            tempCount = tempCount - excess;
     
                            /** sets the cost of the bags inside the first small box */
                            firstSmallBoxCostPerBag = tempCount * COFFEE_BAG_PRICE;
     
                            if ((excess < 5) && (excess != 0)) {
     
                                /**
                                 * this will hold the value of the remaining excess order
                                 */
                                remSmallBoxOrderCount = excess;
                                smallBoxCount++;
     
                                /** sets the cost of the bags in the remaining small box */
                                remSmallBoxCostPerBag = excess * COFFEE_BAG_PRICE;
                            }
                        }
                    }
     
                    orderAgain = reOrder();
                }
                while ((orderAgain == true) && (numberOfOrders < 20));   //IM HAVING PROBLEM WITH THIS PART   
     
                /**
                 * check if the user doesnt want to order again, if not then do this
                 */
                if ((orderAgain == false) && (this.numberOfOrders < 20)) {
     
                    /**
                     * this will ask the user if if he/she wants to include the small orders
                     * to the shipmen
                     */
                    includeOrder = includeToShipment();
     
                    if ((includeOrder.equalsIgnoreCase("Yes")) || (includeOrder.equalsIgnoreCase("Y"))) {
     
                        System.out.print("\n");
                        System.out.println("Your Order Will Be Included Into The Shipment.");
                        System.out.println("Thank You!");
     
                    }
                    /**
                     * if the user doesnt want to include the orders to the shipment
                     * then reset the variables into 0 or none
                     */
                    else if ((includeOrder.equalsIgnoreCase("No")) || (includeOrder.equalsIgnoreCase("n"))) {
     
                        mediumBoxCount = 0;
                        smallBoxCount = 0;
                        firstSmallBoxOrderCount = 0;
                        remSmallBoxOrderCount = 0;
                        singleSmallBoxOrderCount = 0;
                    }
                    else {
     
                        System.out.print("\n");
                        System.out.println("Yes Or No Only.");
                        System.out.println("Invalid Response.");
                        System.out.println("Order Cannot be Included.");
     
                        largeBoxCount = 0;
                        mediumBoxCount = 0;
                        smallBoxCount = 0;
                        firstSmallBoxOrderCount = 0;
                        remSmallBoxOrderCount = 0;
                        singleSmallBoxOrderCount = 0;
                    }
                }
            }
            else if (this.numberOfOrders >= 20) {
     
                /** temporary count for the number of orders, this will make the count
                 * of the bags inside each large box that will be used.
                 */
                tempCount = this.numberOfOrders;
     
                largeBoxOrderCount = 20;
     
                /** do the count for the large boxes that will be used and the excess */
                for (orderCount = this.numberOfOrders; orderCount >= 20; orderCount = orderCount - 20) {
     
                    largeBoxCount++;
                    excess = orderCount - 20;
                }
     
                /** this will make the count for the bags inside the large boxes */
                tempCount = tempCount - excess;
     
                /** sets cost of the bags in the large boxes */
                largeBoxCostPerBag = tempCount * COFFEE_BAG_PRICE;
     
                if (excess >= 10) {
     
                    /** temporary count for the excess that will be assigned in a medium box */
                    tempCount = excess;
     
                    mediumBoxOrderCount = 10;
     
                    for (orderCount = excess; orderCount >= 10; orderCount = orderCount - 10) {
     
                        mediumBoxCount++;
                        excess = orderCount - 10;                 
                    }
     
                    /** this will make the count for the bags in the medium box */
                    tempCount = tempCount - excess;
     
                    /** sets the price of each coffee beans bag in every medium box */
                    mediumBoxCostPerBag = tempCount * COFFEE_BAG_PRICE;
                }
     
                /**
                 * if the excess order count is less than or equal 5 then it will be assigned in
                 * a single small box
                 */
                if ((excess <= 5) && (excess != 0)) {
     
                    tempCount = excess;
                    singleSmallBoxOrderCount = excess;
                    smallBoxCount++;
     
                    /** sets the cost of the bags in a single small box */
                    singleSmallBoxCostPerBag = tempCount * COFFEE_BAG_PRICE;
                }
                /**
                 * else if the excess order is greater than or equal to 5 then it will be assigned
                 * in a 2 small boxes
                 */
                else if (excess >= 5) {
     
                    /** temporary count for the first 5 bags of the excess */
                    tempCount = excess;
     
                    firstSmallBoxOrderCount = 5;
     
                    for (orderCount = excess; orderCount >= 5; orderCount = orderCount - 5){
     
                        smallBoxCount++;
                        excess = orderCount - 5;
     
                    }
     
                    /** this will make the count for the first 5 bags in a small box */
                    tempCount = tempCount - excess;
     
                    /** sets the price of the bags in the first small box */
                    firstSmallBoxCostPerBag = tempCount * COFFEE_BAG_PRICE;
     
                    if ((excess < 5) && (excess != 0)) {
     
                        tempCount = excess;
     
                        /** the remaining excess order will be assinged in another small box */
                        remSmallBoxOrderCount = excess;
                        smallBoxCount++;
                    }
     
                    /** sets the price of the coffee bags in the remaining small box */
                    remSmallBoxCostPerBag = tempCount * COFFEE_BAG_PRICE;
                }         
            }
     
            /** the whole computation of the costs per order */
            totalLargeBoxCostPerOrder = largeBoxCount * LARGE_BOX_PRICE;
            totalMediumBoxCostPerOrder = mediumBoxCount * MEDIUM_BOX_PRICE;
            totalSmallBoxCostPerOrder = smallBoxCount * SMALL_BOX_PRICE;    
            totalBoxesPerOrder = largeBoxCount + mediumBoxCount + smallBoxCount;
            totalBoxesCostPerOrder = totalLargeBoxCostPerOrder + totalMediumBoxCostPerOrder + totalSmallBoxCostPerOrder;
            totalOrderCostPerOrder = largeBoxCostPerBag + mediumBoxCostPerBag + singleSmallBoxCostPerBag
                                     + firstSmallBoxCostPerBag + remSmallBoxCostPerBag;
            shipmentCostPerOrder = totalBoxesCostPerOrder + totalOrderCostPerOrder;
     
            /** this will count the total cost of the whole shipment */
            totalShipmentCost = totalShipmentCost + shipmentCostPerOrder;
     
            /** total count of the large box that was used in the whole shipment */
            totalNumberOfOrders = totalNumberOfOrders + this.numberOfOrders;
            totalCoffeeBeansCost = totalNumberOfOrders * COFFEE_BAG_PRICE;
            totalLargeBox = totalLargeBox + largeBoxCount;
            totalMediumBox = totalMediumBox + mediumBoxCount;
            totalSmallBox = totalSmallBox + smallBoxCount;
            totalLargeBoxCost = totalLargeBox * LARGE_BOX_PRICE;
            totalMediumBoxCost = totalMediumBox * MEDIUM_BOX_PRICE;
            totalSmallBoxCost = totalSmallBox * SMALL_BOX_PRICE;
            totalBoxesInShipment = totalLargeBox + totalMediumBox + totalSmallBox;
     
            /** this will determine how many times the order was done for the whole shipment */
            totalOrderCount++;
        }
     
        /** this will display all the status in a current shipment */
        public void checkShipment() {
     
            System.out.print("\n");
            System.out.println("Total Number Of Coffee Beans Order: " + totalNumberOfOrders);
            System.out.println("Total Cost Of Coffee Beans In The Whole Shipment: " + df.format(totalCoffeeBeansCost));
            System.out.println("Total Order Count For The Whole Shipment: " + totalOrderCount);
     
            System.out.print("\n");
            System.out.println("Total Large Box That Was Used Is: " + totalLargeBox);
            System.out.println("Total Medium Box That Was Used Is: " + totalMediumBox);
            System.out.println("Total Small Box That Was Used Is: " + totalSmallBox);
            System.out.println("Total Of Boxes That Were Is Used: " + totalBoxesInShipment);
     
            System.out.print("\n");
            System.out.println("Total Large Box Cost For The Whole Shipment: " + df.format(totalLargeBoxCost));
            System.out.println("Total Medium Box Cost For The Whole Shipment: " + df.format(totalMediumBoxCost));
            System.out.println("Total Small Box Cost For The Whole Shipment: " + df.format(totalSmallBoxCost));
     
            System.out.print("\n");
            System.out.println("Total Shipment Cost: " + df.format(totalShipmentCost));
        }
     
        /**
         * @return  total cost of the small boxes that was included in the shipment
         */
        public double totalSmallBoxCost() {
     
            return totalSmallBoxCost;
        }
     
        /**
         * @return  total cost of medium boxes that was included in the shipment
         */
        public double totalMediumBoxCost() {
     
            return totalMediumBoxCost;
        }
     
        /**
         * @return  total cost of the large boxes that was included in the shipment
         */
        public double totalLargeBoxCost() {
     
            return totalLargeBoxCost();
        }
     
        /**
         * @return  total cost of the coffee beans in the whole shipment
         */
        public double totalCoffeeBeansCost() {
     
            return totalCoffeeBeansCost;
        }
     
        /**
         * @return  total number of orders in the whole shipment
         */
        public int totalNumberOfOrders() {
     
            return totalNumberOfOrders;
        }
     
        /**
         * @return  total count of the order in the whole shipment
         */
        public int totalOrderCount() {
     
            return totalOrderCount;
        }
     
        /**
         * @return  total number of large box that was included in the shipment
         */
        public int totalLargeBox() {
     
            return totalLargeBox;
        }
     
        /**
         * @return  total number of the medium box that was included in the shipment
         */
        public int totalMediumBox() {
     
            return totalMediumBox;
        }
     
        /**
         * @return  total number of small box that was included in the shipment
         */
        public int totalSmallBox() {
     
            return totalSmallBox;
        }
     
        /**
         * @return  total number of boxes that was used in the whole shipment
         */
        public int totalBoxesInShipment() {
     
            return totalBoxesInShipment;
        }
        /**
         * @return  total cost of the whole shipment
         */
        public double totalShipmentCost() {
     
            return totalShipmentCost;       
        }
     
        public void showOrder() {
     
            System.out.print("\n");
            System.out.println("Client Name: " + clientName);
            System.out.println("Contract Number: " + contractNumber);
            /**
             * this will check the number of the boxes that have been used
             */
            if (largeBoxCount > 1) {
     
                if (mediumBoxCount == 1) {
     
                    if (smallBoxCount > 1) {
     
                        System.out.print("\n");
                        System.out.println(largeBoxCount + " Large Boxes");
                        System.out.println(mediumBoxCount  + " Medium Box");
                        System.out.println(smallBoxCount + " Small Boxes");
                    }
                    else if (smallBoxCount == 1) {
     
                        System.out.print("\n");
                        System.out.println(largeBoxCount + " Large Boxes");
                        System.out.println(mediumBoxCount + " Medium Box");
                        System.out.println(smallBoxCount + " Small Box");
                    }
                    else if (smallBoxCount == 0) {
     
                        System.out.print("\n");
                        System.out.println(largeBoxCount + " Large Boxes");
                        System.out.println(mediumBoxCount + " Medium Box");
                    }
                }
                else if (mediumBoxCount == 0) {
     
                    if (smallBoxCount > 1) {
     
                        System.out.print("\n");
                        System.out.println(largeBoxCount + " Large Boxes");
                        System.out.println(smallBoxCount + " Small Boxes");
                    }
                    else if (smallBoxCount == 1) {
     
                        System.out.print("\n");
                        System.out.println(largeBoxCount + " Large Boxes");
                        System.out.println(smallBoxCount + " Small Box");
                    }
                    else if (smallBoxCount == 0) {
     
                        System.out.print("\n");
                        System.out.println(largeBoxCount + " Large Boxes");
                    }
                }
            }
            else if (largeBoxCount == 1) {
     
                if (mediumBoxCount == 1) {
     
                    if (smallBoxCount > 1) {
     
                        System.out.print("\n");
                        System.out.println(largeBoxCount + " Large Box");
                        System.out.println(mediumBoxCount + " Medium Box");
                        System.out.println(smallBoxCount  + " Small Boxes");
                    }
                    else if (smallBoxCount == 1) {
     
                        System.out.print("\n");
                        System.out.println(largeBoxCount + " Large Box");
                        System.out.println(mediumBoxCount + " Medium Box");
                        System.out.println(smallBoxCount + " Small Box");
                    }
                    else if (smallBoxCount == 0) {
     
                        System.out.print("\n");
                        System.out.println(largeBoxCount + " Large Box");
                        System.out.println(mediumBoxCount + " Medium Box");
                    }
                }
                else if (mediumBoxCount == 0) {
     
                    if (smallBoxCount > 1) {
     
                        System.out.print("\n");
                        System.out.println(largeBoxCount + " Large Box");
                        System.out.println(smallBoxCount + " Small Boxes");
                    }
                    else if (smallBoxCount == 1) {
     
                        System.out.print("\n");
                        System.out.println(largeBoxCount + " Large Box");
                        System.out.println(smallBoxCount + " Small Box");
                    }
                    else if (smallBoxCount == 0) {
     
                        System.out.print("\n");
                        System.out.println(largeBoxCount + " Large Box");
                    }
                }
            }
            else if (largeBoxCount == 0) {
     
                if (mediumBoxCount == 1) {
     
                    if (smallBoxCount > 1) {
     
                        System.out.print("\n");
                        System.out.println(mediumBoxCount + " Medium Box");
                        System.out.println(smallBoxCount + " Small Boxes");
                    }
                    else if (smallBoxCount == 1) {
     
                        System.out.print("\n");
                        System.out.println(mediumBoxCount + " Medium Box");
                        System.out.println(smallBoxCount + " Small Box");
                    }
                    //this will be displayed if the order is exactly 10
                    else if (smallBoxCount == 0) {
     
                        System.out.print("\n");
                        System.out.println(mediumBoxCount + " Medium Box");
                    }
                }
                //if the medium box is 0 then the order is less than 10
                else if (mediumBoxCount == 0) {
     
                    //if there were two small boxes that were used then display this
                    if (smallBoxCount > 1) {
     
                        System.out.print("\n");
                        System.out.println(smallBoxCount + " Small Boxes");
                    }
                    //else if the there is only a single small box used then display this
                    else if (smallBoxCount == 1) {
     
                        System.out.print("\n");
                        System.out.println(smallBoxCount + " Small Box");
                    }
                }
            }
     
            /**
             * this will check the number of orders in each box that was used
             */
            if (largeBoxCount > 1) {
     
                if (mediumBoxCount == 1) {
     
                    if (smallBoxCount > 1) {
     
                        System.out.print("\n");
                        System.out.println("Each Large Box Contains " + largeBoxOrderCount + " Orders");
                        System.out.println("Medium Box Contains " + mediumBoxCount + " Orders");
                        System.out.println("The Firs Small Box Contains " + firstSmallBoxOrderCount + " Orders");
     
                        if (excess > 1) {
     
                            System.out.println("The Remaining Small Box Contains " + remSmallBoxOrderCount + " Orders");
                        }
                        else if (excess == 1) {
     
                            System.out.println("The Remaining Small Box Contains " + remSmallBoxOrderCount + " Order");
                        }
                    }
                    else if (smallBoxCount == 1) {
     
                        System.out.print("\n");
                        System.out.println("Each Large Box Contains " + largeBoxOrderCount + " Orders");
                        System.out.println("Medium Box Contains " + mediumBoxOrderCount  + " Orders");
     
                        if (excess > 1) {
     
                            System.out.println("The Small Box Contains " + singleSmallBoxOrderCount + " Orders");
                        }
                        else if (excess == 1) {
     
                            System.out.println("The Small Box Contains " + singleSmallBoxOrderCount + " Order");
                        }
                    }
                    else if (smallBoxCount == 0) {
     
                        System.out.print("\n");
                        System.out.println("Each Large Box Contains " + largeBoxOrderCount + " Orders");
                        System.out.println("Medium Box Contains " + mediumBoxOrderCount + " Orders");
                    }
                }
                else if (mediumBoxCount == 0) {
     
                    if (smallBoxCount > 1) {
     
                        System.out.print("\n");
                        System.out.println("Each Large Box Contains " + largeBoxOrderCount +  " Orders");
                        System.out.println("First Small Box Contains " + firstSmallBoxOrderCount + " Orders");
     
                        if (excess > 1) {
     
                            System.out.println("The Remaining Small Box Contains " + remSmallBoxOrderCount + " Orders");
                        }
                        else if (excess == 1) {
     
                            System.out.println("The Remaining Small Box Contains " + remSmallBoxOrderCount + " Order");
                        }
                    }
                    else if (smallBoxCount == 1) {
     
                        System.out.print("\n");
                        System.out.println("Each Large Box Contains " + largeBoxOrderCount + " Orders");
     
                        if (excess > 1) {
     
                            System.out.println("Small Box Contains " + singleSmallBoxOrderCount + " Orders");
                        }
                        else if (excess == 1) {
     
                            System.out.println("Small Box Contain " + singleSmallBoxOrderCount  + " Order");
                        }
                    }
                    else if (smallBoxCount == 0) {
     
                        System.out.print("\n");
                        System.out.println("Each Large Box Contains " + largeBoxOrderCount + " Orders");
                    }
                }
            }
            else if (largeBoxCount == 1) {
     
                if (mediumBoxCount == 1) {
     
                    if (smallBoxCount > 1) {
     
                        System.out.print("\n");
                        System.out.println("A Single Large Box Contains " + largeBoxOrderCount + " Orders");
                        System.out.println("Medium Box Contains " + mediumBoxOrderCount + " Orders");
                        System.out.println("The First Small Box Contains " + firstSmallBoxOrderCount + " Orders");
     
                        if (excess > 1) {
     
                            System.out.println("The Remaining Small Box Contains " + remSmallBoxOrderCount + " Orders");
                        }
                        else if (excess == 1) {
     
                            System.out.println("The Remaining Small Box Contains " + remSmallBoxOrderCount + " Order");
                        }
                    }
                    else if (smallBoxCount == 1) {
     
                        System.out.print("\n");
                        System.out.println("A Single Large Box Contains " + largeBoxOrderCount + " Orders");
                        System.out.println("Medium Box Contains " + mediumBoxOrderCount + " Orders");
     
                        if (excess > 1) {
     
                            System.out.println("Small Box Contains " + singleSmallBoxOrderCount + " Orders");
                        }
                        else if (excess == 1) {
     
                            System.out.println("Small Box Contains " + singleSmallBoxOrderCount + " Order");
                        }
                    }
                    else if (smallBoxCount == 0) {
     
                        System.out.print("\n");
                        System.out.println("A Single Large Box Contains " + largeBoxOrderCount + " Orders");
                        System.out.println("Medium Box Contains " + mediumBoxOrderCount + " Orders");
                    }
                }
                else if (mediumBoxCount == 0) {
     
                    if (smallBoxCount > 1) {
     
                        System.out.print("\n");
                        System.out.println("A Single Large Box Contains " + largeBoxOrderCount + " Orders");
                        System.out.println("The First Small Box Contains " + firstSmallBoxOrderCount + " Orders");
     
                        if (excess > 1) {
     
                            System.out.println("The Remaining Small Box Contains " + remSmallBoxOrderCount + " Orders");
                        }
                        else if (excess == 1) {
     
                            System.out.println("The Remaining Small Box Contains " + remSmallBoxOrderCount + " Order");
                        }
                    }
                    else if (smallBoxCount == 1) {
     
                        System.out.print("\n");
                        System.out.println("A Single Large Box Contains " + largeBoxOrderCount + " Orders");
     
                        if (excess > 1) {
     
                            System.out.println("Small Box Contains " + singleSmallBoxOrderCount + " Orders");
                        }
                        else if (excess == 1) {
     
                            System.out.println("Small Box Contains " + singleSmallBoxOrderCount + " Orders");
                        }
                    }
                    else if (smallBoxCount == 0) {
     
                        System.out.print("\n");
                        System.out.println("A Single Large Box Contains " + largeBoxOrderCount + " Orders");
                    }
                }
            }
            else if (largeBoxCount == 0) {
     
                if (mediumBoxCount == 1) {
     
                    if (smallBoxCount > 1) {
     
                        System.out.print("\n");
                        System.out.println("Medium Box Contains " + mediumBoxOrderCount + " Orders");
                        System.out.println("The First Small Box Contains " + firstSmallBoxOrderCount + " Orders");
     
                        if (excess > 1) {
     
                            System.out.println("The Remaining Small Box Contains " + remSmallBoxOrderCount + " Orders");
                        }
                        else if (excess == 1) {
     
                            System.out.println("The Remaining Small Box Contains " + remSmallBoxOrderCount + " Order");
                        }
                    }
                    else if (smallBoxCount == 1) {
     
                        System.out.print("\n");
                        System.out.println("Medium Box Contains " + mediumBoxOrderCount + " Orders");
     
                        if (excess > 1) {
     
                            System.out.println("The Small Box Contains " + singleSmallBoxOrderCount + " Orders");
                        }
                        else if ((excess == 1) && (excess != 0)) {
     
                            System.out.println("The Small Box Contains " + singleSmallBoxOrderCount + " Order");
                        }
                    }
                    else if (smallBoxCount == 0) {
     
                        System.out.print("\n");
                        System.out.println("Medium Box Contains " + mediumBoxOrderCount + " Orders");
                    }
                }
                else if (mediumBoxCount == 0) {
     
                    if (smallBoxCount > 1) {
     
                        System.out.print("\n");
                        System.out.println("The First Small Box Contains " + firstSmallBoxOrderCount + " Orders");
     
                        if (excess > 1) {
     
                            System.out.println("The Remaining Small Box Contains " + remSmallBoxOrderCount + " Orders");
                        }
                        else if (excess == 1) {
     
                            System.out.println("The Remaining Small Box Contains " + remSmallBoxOrderCount + " Order");
                        }
                    }
                    else if (smallBoxCount == 1) {
     
                        System.out.print("\n");
                        System.out.println("A Single Box Contains " + singleSmallBoxOrderCount + " Orders");
     
                    }
                }
            }
     
     
            System.out.print("\n");
            System.out.println("TotalBoxes Used: " + totalBoxesPerOrder);
            System.out.print("\n");
     
            /**
             * this will check if there any box that was not used before
             * displaying the costs of each box that was used
             */
            if (largeBoxCount >= 1) {
     
                if (mediumBoxCount == 1) {
     
                    if (smallBoxCount >= 1) {
     
                        System.out.println("Total Large Box Cost For This Order: " + "$" + df.format(totalLargeBoxCostPerOrder));
                        System.out.println("Total Medium Box Cost For This Order: " + "$" + df.format(totalMediumBoxCostPerOrder));
                        System.out.println("Total Small Box Cost: " + " " + df.format(totalSmallBoxCostPerOrder));
                    }
                    else if (smallBoxCount == 0) {
     
                        System.out.println("Total Large Box Cost For This Order: " + "$" + df.format(totalLargeBoxCostPerOrder));
                        System.out.println("Total Medium Box Cost For This Order: " + "$" + df.format(totalMediumBoxCostPerOrder));
                    }
                }
                else if (mediumBoxCount == 0) {
     
                    if (smallBoxCount >= 1) {
     
                        System.out.println("Total Large Box Cost For This Order: " + "$" + df.format(totalLargeBoxCostPerOrder));
                        System.out.println("Total Small Box Cost For This Order: " + " " + df.format(totalSmallBoxCostPerOrder));
                    }
                    else if (smallBoxCount == 0) {
     
                        System.out.println("Total Large Box Cost For This Order: " + "$" + df.format(totalLargeBoxCostPerOrder));
                    }
                }
            }
            else if (largeBoxCount == 0) {
     
                if (mediumBoxCount == 1) {
     
                    if (smallBoxCount >= 1) {
     
                        System.out.println("Total Medium Box Cost For This Order: " + "$" + df.format(totalMediumBoxCostPerOrder));
                        System.out.println("Total Small Box Cost For This Order: " + " " + df.format(totalSmallBoxCostPerOrder));
                    }
                }
                else if (mediumBoxCount == 0) {
     
                    if (smallBoxCount >= 1) {
     
                        System.out.println("Total Small Box Cost For This Order: " + " " + df.format(totalSmallBoxCostPerOrder));
                    }
                }
            }     
     
            System.out.print("\n");
            System.out.println("Total Boxes Cost For This Order: " + "$" + df.format(totalBoxesCostPerOrder));
            System.out.println("Total Order Cost For This Order: " + "$" + df.format(totalOrderCostPerOrder));
     
            System.out.print("\n");
            System.out.println("Shipment Cost For This Order: " + "$" + df.format(shipmentCostPerOrder));
        }
     
         /** method that will ask the user to order again if the order is below 20
          *
          * @return   true if the entered string value is equal to ignored case of "y"
          *           or "yes, false if "n" or "no" else return false
          *
          * @throws   IOException
          *
          */
         private boolean reOrder() throws IOException {
     
             String reOrder;
     
             System.out.print("\n");
             System.out.print("Do You Want To Order Again?: ");
             reOrder = br.readLine();
     
             if ((reOrder.equalsIgnoreCase("Y")) || (reOrder.equalsIgnoreCase("YES"))) {
     
                 mediumBoxCount = 0;
                 smallBoxCount = 0;
                 excess = 0;
                 numberOfOrders = 0;
                 orderCount = 0;
                 firstSmallBoxOrderCount = 0;
                 remSmallBoxOrderCount = 0;
                 singleSmallBoxOrderCount = 0;
                 mediumBoxOrderCount = 0;
    /*
     orderAgain = false;
    totalOrderCount = 0;
     tempCount = 0;
       numberOfOrders = 0;
      largeBoxCount = 0;
    mediumBoxCount = 0;
    smallBoxCount = 0;
     orderCount = 0;
    largeBoxOrderCount = 0;
    mediumBoxOrderCount = 0;
    firstSmallBoxOrderCount = 0;
    remSmallBoxOrderCount = 0;
    singleSmallBoxOrderCount = 0;
      excess = 0;
      totalBoxesPerOrder = 0;
    totalLargeBox = 0;
     totalMediumBox = 0;
    totalSmallBox = 0;
    totalBoxesInShipment = 0;
    contractNumber = 0L;
    shipmentCostPerOrder = 0.0;
    totalOrderCostPerOrder = 0.0;
    largeBoxCostPerBag = 0.0;
     mediumBoxCostPerBag = 0.0;
    firstSmallBoxCostPerBag = 0.0;
       remSmallBoxCostPerBag = 0.0;
      singleSmallBoxCostPerBag = 0.0;
     totalLargeBoxCostPerOrder = 0.0;
     totalMediumBoxCostPerOrder = 0.0;
     totalSmallBoxCostPerOrder = 0.0;
    totalBoxesCostPerOrder = 0.0;
    totalShipmentCost = 0.0;
    totalLargeBoxCost = 0.0;
    totalMediumBoxCost = 0.0;
    totalSmallBoxCost = 0.0;
    totalCoffeeBeansCost = 0.0;
       totalNumberOfOrders = 0;
    clientName = "";
            includeOrder = "";
    */
                 System.out.print("\n");
                 System.out.print("Enter Your New Order: ");
                 numberOfOrders = Integer.parseInt(br.readLine());
     
                 setOrder(numberOfOrders, contractNumber, clientName);
     
                 return true;
             }
             else if ((reOrder.equalsIgnoreCase("N")) || (reOrder.equalsIgnoreCase("NO"))) {
     
                 return false;
             }
             else {
     
                 return false;
             }
         }
     
         /**
          * method that will ask if the user wants to perform new order for the
          * current shipment
          * 
          * @return true if the string value that is entered is equals to ignored case
          *         of "y", or "yes", false if "n" or "no" else return false
          * 
          * @throws IOException
          */
         public boolean nextOrder() throws IOException {
     
             String cont;
     
             System.out.print("\n");
             System.out.print("Proceed To Next Order? :");
             cont = br.readLine();
     
             if ((cont.equalsIgnoreCase("Y")) || (cont.equalsIgnoreCase("YES"))) {
     
                 reset();
                 System.out.print("\n");
                 System.out.println("-------------------------------------------------");
                 System.out.print("\n");
                 return true;
             }
             else if ((cont.equalsIgnoreCase("N")) || (cont.equalsIgnoreCase("NO"))) {
     
                 return false;
             }
             else {
     
                 return false;
             }
         }
     
         /**
          * 
          * @return
          * @throws IOException
          */
         private String includeToShipment() throws IOException {
     
            String keyIn;
     
            System.out.print("\n");
            System.out.print("Do You Want To Include Your Orders Into The Shipment?: ");
            keyIn = br.readLine();
     
            if (keyIn.equals("Y")) {
     
                return "Y";
            }
            else if (keyIn.equals("y")) {
     
                return "y";
            }
            else if (keyIn.equals("YES")) {
     
                return "YES";
            }
            else if (keyIn.equals("yes")) {
     
                return "yes";
            }
            else if (keyIn.equals("N")) {
     
                return "N";
            }
            else if (keyIn.equals("n")) {
     
                return "n";
            }
            else if (keyIn.equals("NO")) {
     
                return "NO";
            }
            else if (keyIn.equals("no")) {
     
                return "no";
            }
            /**
             * If the entered String is not equals to ignored cases of "n", "no", "y" and "yes",
             * return an empty String value
             */
            else {
     
                return "";
            }
        }
     
        private void reset() {
     
            orderAgain = false;
            tempCount = 0;
            numberOfOrders = 0;
            largeBoxCount = 0;
            mediumBoxCount = 0;
            smallBoxCount = 0;
            orderCount = 0;
            largeBoxOrderCount = 0;
            mediumBoxOrderCount = 0;
            firstSmallBoxOrderCount = 0;
            remSmallBoxOrderCount = 0;
            singleSmallBoxOrderCount = 0;
            excess = 0;
            largeBoxCostPerBag = 0;
            mediumBoxCostPerBag = 0;
            firstSmallBoxCostPerBag = 0.0;
            remSmallBoxCostPerBag = 0.0;
            singleSmallBoxCostPerBag = 0.0;
            totalBoxesPerOrder = 0;
            contractNumber = 0L;
            shipmentCostPerOrder = 0.0;
            totalLargeBoxCostPerOrder = 0.0;
            totalMediumBoxCostPerOrder = 0.0;
            totalSmallBoxCostPerOrder = 0.0;
            totalBoxesCostPerOrder = 0;
            totalOrderCostPerOrder = 0.0;
            clientName = "";
            includeOrder = "";
        }
    }


    try to run it by entering 10 .. using this class in a main program
    Last edited by helloworld922; October 26th, 2009 at 10:25 AM.


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Parameter's value is never changing

    No where in your code is it changing numberOfOrders. Also, your method is using a field variable to operate in a recursive function. I would recommend passing the value to the recursive method instead of using a class field.

  3. #3
    Java kindergarten chronoz13's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    659
    Thanks
    177
    Thanked 30 Times in 28 Posts

    Default Re: Parameter's value is never changing

    wha ... im not yet with that part "recursion" ... so you notice it too?? that part of numberOfOrders in the while loop... the block that will be executed if you enter 10.... whaaaa


    kinda confuse here....

  4. #4
    Java kindergarten chronoz13's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    659
    Thanks
    177
    Thanked 30 Times in 28 Posts

    Default Re: Parameter's value is never changing

    i cant apply the logic that .. programs are executed sequentially.... what i understand with that .. is that it is literally executing SEQUENTIALLY ,,, am i miising something with here? is only a "recursion"??


    whaaa i forgot to read your post about General CS concepts..... that recursion part... T_T

  5. #5
    Member
    Join Date
    Oct 2009
    Posts
    52
    Thanks
    0
    Thanked 6 Times in 5 Posts

    Default Re: Parameter's value is never changing

    There is nothing non-sequential about recursion.

    Recursion means that a method calls itself within its own method body. As long as there is a case where the recursion can be stopped, then you will be ok.

    public static int factorial(int num) {
        if (n == 1)
            return 1;
        else
            return num * factorial(num - 1);
    }

    Calling: factorial(5) will return 5 * 4 * 3 * 2 * 1 which will literally be 120.

    Does this code make sense?

  6. #6
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Parameter's value is never changing

    Yes, you're SetOrder is calling reOrder, but reOrder is calling SetOrder, so your call stack looks like this (choosing order size 10, then second order size 20)

    1. setOrder (version a)
    2. reOrder
    3. setOrder (version b)

    in setOrder (version a), numberOfOrders = 20, but when that returns to reOrder, the program has forgotten that numberOfOrders = 20 because that copy of the variable has gone out of scope. reOrder then returns true because you answered that you did want to re-order. setOrder (version b) still has numberOfOrders = 10 (different from the one in numberOfOrders = 20), and gets back true from reOrder. It then tests numberOfOrders < 20 (true, since it equals 10), and basically the whole process starts again (number of orders is too small, da da da da da)

  7. #7
    Java kindergarten chronoz13's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    659
    Thanks
    177
    Thanked 30 Times in 28 Posts

    Default Re: Parameter's value is never changing

    ahh so its the flow of data.. nothing makes different whether i change the variable......
    ill try to deal with this one... ill just post if there any further questions.. tnx world! tnx guys!

Similar Threads

  1. Changing colors of large image in real time
    By chals in forum Java ME (Mobile Edition)
    Replies: 1
    Last Post: May 7th, 2009, 06:06 AM