Code example for Scanner

Methods: close, nextDouble

0
  public static void main(String[] args)
    { 
    /*************************************************************************** 
    * Properties 
    ***************************************************************************/ 
    Scanner input = new Scanner(System.in);
    double  purchaseAmount;
    double  tax;
     
    System.out.print("Enter purchase amount: ");
    purchaseAmount = input.nextDouble();
    input.close();
     
    tax = purchaseAmount * 0.06;
    System.out.println("Sales tax is $" + (int)(tax*100)/100.0);
    } 
  }