/*
   Project 3:	 Making Decisions
   Programmer:	 Gary Haines
   Date: 	 January 27, 2003
   Program Name: Candle
*/

import java.io.*;

public class Candle
{
    public static void main(String[] args) throws IOException
    {
	//Declaring Variables
	BufferedReader dataIn = new BufferedReader(new InputStreamReader(System.in));
	String strPrice;
	String strDays;
	double price;
	int days;
	double shipping;
	boolean done = false;

	while(!done)
	{
	
	try
	{
	    //Get input from user
	    System.out.println("What is the total dollar amount of your order?");
		strPrice = dataIn.readLine();
		price = Double.parseDouble(strPrice);

	    if (price <= 0)
	    {
		System.out.println("\tYou must enter a number greater than zero.");
		throw new NumberFormatException();
	    }

	    System.out.println("What is your shipping priority?");
		System.out.println();
		System.out.println("\t1) Priority (Overnight)");
		System.out.println("\t2) Express (2 business days)");
		System.out.println("\t3) Standard (3 to 7 business days)");
		strDays = dataIn.readLine();
		days = Integer.parseInt(strDays);

	    //Call method to get a valid shipping charge
	    shipping = getCost(price, days);
	    done = true;
	    
	    //Display Output
	    System.out.println();
	    System.out.println("The shipping charge is $" + (shipping));
	    System.out.println("The total charge will be $" + (price + shipping));
	    System.out.println();
	    System.out.println("\t\t\tThank you for ordering from CandleLine");

	}

	catch (NumberFormatException e)
	{
	    System.out.println("\tYour response was not a valid number.");
	    System.out.println("\tPlease reenter your order using a numeric value.");
	    System.out.println();
	}
	
	}
    }
    
    public static double getCost(double price, int days)
    {
	double shipping;
	switch (days)
	{
	  case 1:
	  	shipping = 14.95;
		break;
	  case 2:
		shipping = 11.95;
		break;
	  case 3:
		if (price > 75)
			shipping = 0;
		else
			shipping = 5.95;
		break;
	  default:
		throw new NumberFormatException();
	}
	return shipping;
    }
}