Code example for Scanner

Methods: nextDoublenextInt

0
package chapter3; 
 
import java.util.Scanner;  
 
public class ComputeTax { 
  public static void main(String[] args) {
    // Create a Scanner 
    Scanner input = new Scanner(System.in);
 
    // Prompt the user to enter filing status 
    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();
 
    // 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