Code example for Scanner

Methods: nextDoublenextInt

0
 * @author Administrator 
 */ 
import java.util.Scanner; 
public class Q7_12 { 
    public static void main(String[] args)  {
        Scanner input = new Scanner(System.in);
        double[] rates = {0.10, 0.15, 0.25, 0.28, 0.33, 0.35};
         
        int[][] brackets = {
            {8350, 33950, 82250, 171550, 372950}, // Single filer 
            {16700, 67900, 137050, 20885, 372950}, // Married jointly 
            {8350, 33950, 68525, 104425, 186475}, // Married separately 
            {11950, 45500, 117450, 190200, 372950} // Head of household 
        }; 
        System.out.print(
            "(0-single filer, 1-married jointly,\n" + 
            "2-married separately, 3-head of household)\n" + 
            "Enter the filing status: "); 
        int status = input.nextInt();
         
        System.out.print("Enter the taxable income: ");
        double income = input.nextDouble();
        double tax = 0;
         
        if (income < brackets[status][0])
            tax = income * rates[0];
        else if (income < brackets[status][1])