
/*
**********************************************************************************
This file is: http://www.annedawson.com/EggBasket.java
Author: Walter Savitch
Last updated with comments: Saturday 15th September 2007, 11:25 PT by AHD

Please note: all textbook source code from the 4th Ed textbook can be found here:

http://www.annedawson.com/java4th.zip

****   REALLY, REALLY, IMPORTANT:   ****
*
*Read ALL the comments that follow...

Any Java program file that uses the SavitchIn class MUST have the SavitchIn.java
file in the same folder.

Get SavitchIn.java here: 
http://www.annedawson.com/SavitchIn.java
or extract from:
http://www.annedawson.com/java4th.zip



SavitchIn.java should be opened in JCreator, and compiled to the class file
BEFORE attempting to compile and execute the java program (in the same folder)
that uses the SavitchIn class.

NOTE: You can Build -> Compile with SavitchIn.java but you cannot run it by using
Build -> Execute File. This is because SavitchIn.java is not designed to run on its own.
Hence it doesn't have a main method. Rather, SavitchIn.java is compiled to the SavitchIn.class
so that other java programs can use the methods (functions) of the class SavitchIn. 

The example programs in the latest version of the textbook (to date: 4th Ed) 
uses the Scanner class INSTEAD of the SavitchIn class. 

The Scanner class is automatically supplied by your java installation, 
so you can use it without having to have explicit access to the code.
This means that you don't need to compile any extra java files.

In course CSCI102, you can use the Scanner class or the SavitchIn class. 
The choice is yours.  Both work well. 


**********************************************************************************
*/


public class EggBasket
{
    public static void main(String[] args)
    {
        int numberOfBaskets, eggsPerBasket, totalEggs;
       
        System.out.println("Enter the number of eggs in each basket:");
         eggsPerBasket = SavitchIn.readLineInt(); 
        System.out.println("Enter the number of baskets:");
        numberOfBaskets = SavitchIn.readLineInt();
     
         totalEggs = numberOfBaskets * eggsPerBasket;
       
        System.out.println(eggsPerBasket + " eggs per basket."); 
        System.out.println(numberOfBaskets + " baskets."); 
        System.out.println("Total number of eggs is " + totalEggs);
       
        eggsPerBasket = eggsPerBasket - 2;
         totalEggs = numberOfBaskets * eggsPerBasket;

        System.out.println("Now we take two eggs out of each basket.");
        System.out.println(eggsPerBasket + " eggs per basket."); 
        System.out.println(numberOfBaskets + " baskets."); 
        System.out.println("Total number of eggs is " + totalEggs); 

        System.out.println("Press enter key to end program.");
        String junk;
        junk = SavitchIn.readLine();
    } 
}