Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Your objective for this test is to write a simple program that determines your t

ID: 3798904 • Letter: Y

Question

Your objective for this test is to write a simple program that determines your tax liability for the year.

Your program must perform the following for one customer:

1. Read the user’s first name and last name

2. Read 4 digit ID number

3. Read the number of family members including you

4. Read the total income for the year

5. Calculate the taxable income and taxes based on the formula given below

6. Output the input, given, and calculated values using output manipulators as shown below

Tax rate = 15%

Tax = taxable income * tax rate

Your program output must be identical to the following screenshot.

Welcome to the ATM Tax Machine Your One Stop Tax Shop Please provide the follwing information Please enter your first and last name Siri Gowri You entered i ri Gown. Please enter your 4 digit ID number 1234 You entered 1234 Please enter number of family members including you 3 You entered 3 Please enter your total income for the year 61255 You entered $61 255 123456789012 34 5678901234 56789O12 34 56789O1 234, 567 89O1234 5 6789O Sir i Gowri 1234 NAME FIRST NAME LAST ID NUMBER 1 2 4 56789O1 2345678901234567 8901 234 5678901 2 3 4 56789 O1234 56789O Number of Family Members Income 612 55 OO Taxable Income 58255 OO O. 15 Tax Rate 8738.25 Totaal Tax Thank you for your Business Press any key to Continue

Explanation / Answer

import java.util.Scanner;

public class ATMTaxMachine {

   /**
   * @param args
   */
   public static void main(String[] args) {
       // TODO Auto-generated method stub

       Scanner scanner = null;

       try {
           scanner = new Scanner(System.in);
           System.out.println("       Test 1 : ATM Tax Machine   ");
           printSymbols(60, "*");
           System.out.println("welcome to the ATM Tax Machine!");
           System.out.println("Your one Stop Tax Machine");
           printSymbols(60, "*");

           System.out.println("Please provide the following information:");
           System.out.print("Please enter your first and last name: ");
           String fname = scanner.next();
           String lname = scanner.next();
           System.out.println("You entered " + fname + " " + lname);
           System.out.print("Please enter your 4 digit ID number: ");
           int id = scanner.nextInt();
           System.out.println("You entered " + id);
           System.out
                   .print("Please enter number of family members including you: ");
           int noofMem = scanner.nextInt();

           System.out.println("You entered " + noofMem);

           System.out.print("Please enter your total income for the year: ");
           int income = scanner.nextInt();
           System.out.println("You entered $" + income);

           printNum(6);
           printSymbols(60, "=");

           System.out.println(fname + " " + lname + " " + id);

           printSymbols(20, "-");

           System.out.println("FIRST NAME LAST NAME ID NUMBER");
           printSymbols(20, "-");

           printNum(6);

           System.out.println("Number of Family Members............."
                   + noofMem);
           System.out.println("Income................................"
                   + income);
           double taxableIncome = (income - 1000 * noofMem);
           double taxRate = 0.15;

           System.out.printf("Taxable Income.........................%.2f ",
                   taxableIncome);
           System.out.printf("Tax Rate...............................%.2f ",
                   taxRate);

           double tax = taxableIncome * taxRate;
           System.out.printf("Total Tax...............................%.2f ",
                   tax);
           printSymbols(60, "=");
           System.out.println("Thank you for your Business");
           System.out.println("Press any key to continue...");

       } catch (Exception e) {
           // TODO: handle exception
       }

   }

   public static void printSymbols(int n, String symbol) {

       for (int i = 0; i < n; i++) {

           System.out.print(symbol);

       }
       System.out.println();
   }

   public static void printNum(int n) {

       for (int i = 0; i < n; i++) {
           for (int j = 1; j < 10; j++) {

               System.out.print(j);
           }
           System.out.print("0");

       }
       System.out.println();
   }

}

OUTPUT:

       Test 1 : ATM Tax Machine  
************************************************************
welcome to the ATM Tax Machine!
Your one Stop Tax Machine
************************************************************
Please provide the following information:
Please enter your first and last name: Siri Gowri
You entered Siri Gowri
Please enter your 4 digit ID number: 1234
You entered 1234
Please enter number of family members including you:
3
You entered 3
Please enter your total income for the year: 61255
You entered $61255
123456789012345678901234567890123456789012345678901234567890
============================================================
Siri   Gowri   1234
--------------------
FIRST NAME    LAST NAME    ID NUMBER
--------------------
123456789012345678901234567890123456789012345678901234567890
Number of Family Members.............3
Income................................61255
Taxable Income.........................58255.00
Tax Rate...............................0.15
Total Tax...............................8738.25
============================================================
Thank you for your Business
Press any key to continue...