import java.util.Scanner;

/**********************************************************************
 * Programming Assignment 2: JMmoo Dairy Bar
 * 
 * @author Ruben Prieto-Diaz
 * @version 1 - 10/5/06 Use of if-else structures
 *********************************************************************/

public class JMmooDairyBar
{
   /******************************************************************
    * Method purpose: excercise and demonstrate knowledge of if-else
	 *                 structures.
    *
    * @param args Command line arguments, ignored
    *****************************************************************/
   public static void main(String [] args)
   {
      Scanner  keyboard;	       // Used to define input Stream
      String   wantSpecialString; // User input: Y or y to indicate Special
		String   wantSprinkles;     // To indicate sprinkles
		String   coneAnswer;        // To indicate kind of cone wanted
		char     SpecialChar;       // One char reduction for Special
		char     sprinklesChar;     // One char reduction for sprinkles
		char     coneChar;          // One char reduction for cone kind
		int      Scoops;            // Number of scoops wanted
		double   ScoopsPrice;       //Price of scoops 1.95 + as many scoops > 1 times $1
		double   TotalPrice;        //Total price to pay
		double   SprinklesCost;     // Cost of having sprinkles
	  
	  	 //Assigning dummi values to working variables
		   ScoopsPrice = 1.0;
		   TotalPrice = 1.95;
		   SprinklesCost = 0.0; 		 
		   Scoops = 0;

      //*****************
      // Welcome customer and input data
      //*****************
	   // Create a Scanner 
		
		keyboard = new Scanner(System.in); //used to input request(s)
		
		System.out.print("Welcome to the JMmoo Dairy Bar\n\n");
		System.out.print("Do you want the special? ");
		wantSpecialString = keyboard.nextLine(); //Get input answer as a string
		SpecialChar = wantSpecialString.charAt(0);  //Get first character: Y , y, N or n
		  		 		
		if (!(SpecialChar == 'y' || SpecialChar == 'Y')) //in case the answer is not or NOT y or NOT Y
		 {
			 System.out.print("\nHow many scoops?  ");
			 Scoops = keyboard.nextInt();
			 
			 if(Scoops <= 0) 
			 {
			 System.out.print("\nNeed to enter a number of scoops" +
			                  " greater than 0 Try again\n");
			 System.exit(3);
			 }
			 if(Scoops-1 == 0)ScoopsPrice = 1.95;
			 if(Scoops-1 > 0) ScoopsPrice = 1.95 + (Scoops-1) * 1.0; 
		   
			 keyboard.nextLine(); //Consume remaining newline before reading next string
 
			 System.out.print("\nDo you want sprinkles? ");
			 wantSprinkles = keyboard.nextLine(); //Get answer for sprinkles
			 sprinklesChar = wantSprinkles.charAt(0);  //Get first char of answer
			 if(sprinklesChar == 'y' || sprinklesChar == 'Y')SprinklesCost = .50;
			 
			 System.out.print("\nWhat kind of cone? (r-regular, s-sugar, w-waffle) ");
			 coneAnswer = keyboard.nextLine();  //Get request for cone kind in string form.
			 coneChar = coneAnswer.charAt(0); //Get r, s or w character from input
			 if(coneChar == 'r' || coneChar == 'R')TotalPrice = ScoopsPrice + SprinklesCost;
			 if(coneChar == 's' || coneChar == 'S')TotalPrice = ScoopsPrice + SprinklesCost + .50;
			 if(coneChar == 'w' || coneChar == 'W')TotalPrice = ScoopsPrice + 1.25;
		  }
		  else TotalPrice = 4.00; 
		 
		  System.out.printf("\nThat will be $%4.2f please.\n", TotalPrice);
		  
		 }
}