Code example for Scanner

Methods: nextDoublenextInt

package chapter3; 
import java.util.Scanner;  
public class ComputeTax { 
  public static void main(String[] args) {
    // Create a Scanner 
    Scanner input = new Scanner(;
    // Prompt the user to enter filing status 
      "(0-single filer, 1-married jointly,\n" + 
      "2-married separately, 3-head of household)\n" + 
      "Enter the filing status: "); 
    int status = input.nextInt();
    // Prompt the user to enter taxable income 
    System.out.print("Enter the taxable income: ");
    double income = input.nextDouble();
    // Compute tax 
    double tax = 0;
    if (status == 0) { // Compute tax for single filers
Connect your IDE to all the code out there  Get Codota for Java