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

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 Taxable income = (Income – 1000*number of family members)

Tax rate = 15%

Tax = taxable income * tax rate

Your program output must be identical to the following screenshot.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

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 + "\t" + lname + "\t" + id);

           printSymbols(20, "-");

           System.out.println("FIRST NAME \t LAST NAME \t 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\n",
                   taxableIncome);
           System.out.printf("Tax Rate...............................%.2f\n",
                   taxRate);

           double tax = taxableIncome * taxRate;
           System.out.printf("Total Tax...............................%.2f\n",
                   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...

Add a comment
Know the answer?
Add Answer to:
Your objective for this test is to write a simple program that determines your tax liability...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • You are hired by a college to write a Java program to use a so-called check...

    You are hired by a college to write a Java program to use a so-called check sum technique for catching typing errors of student ID. The college assigns a seven-digit number to each student. The seventh digit (i.e., the rightmost digit) is determined from the other digits with the use of the following formula: 7th digit = (1 *(1st digit) * 2 * (2nd digit) * ... * 6 * (6th digit)) % 10 Your program should prompt users to...

  • build a phone number from digits entered by your user. Your program will loop until 10...

    build a phone number from digits entered by your user. Your program will loop until 10 valid digits have been entered. It will then use those digits to display the phone number entered using the format: XXXXXXXXXX (or (XXX) XXX – XXXX for extra credit). The program will ask for a digit, it will check to see if the digit is actually between 0 and 9 inclusively. If so, the digit will be stored as the next number in the...

  • In Language = C Concepts for this are (malloc/realloc, structs, and stdin/fgets/getc/scanf) Description Your program will...

    In Language = C Concepts for this are (malloc/realloc, structs, and stdin/fgets/getc/scanf) Description Your program will ask the user to type in the following information: First Name: Last Name: ID#: Email: The program will terminate when a single . is entered as a First Name. This information will be stored in the following structure type: struct student { int recordCount; char *firstName; char *lastName; char *id; char *email; } recordCount is a number assigned at the beginning of the program...

  • the user should be prompted to enter an integer and then your program will produce another...

    the user should be prompted to enter an integer and then your program will produce another integer depending on whether the input was even or odd. The following is an example of what you might see when you run the program; the input you type is shown in green (press Enter at the end of a line), and the output generated by the program is shown in black text. Enter an integer: 1234 Number is even, taking every other digit...

  • Write a program in Python to solve the following task: In this project, you will build...

    Write a program in Python to solve the following task: In this project, you will build a phone number from digits entered by your user. Your program will loop until 10 valid digits have been entered. It will then use those digits to display the phone number entered using the format: XXXXXXXXXX (or (XXX) XXX – XXXX for extra credit). The program will ask for a digit, it will check to see if the digit is actually between 0 and...

  • Using c++ write a program using a class that has   data members ID#,NAME, SALARY, YEAR_HIRED. This...

    Using c++ write a program using a class that has   data members ID#,NAME, SALARY, YEAR_HIRED. This program must 1) write 10 blank records to a random access file. You must enter data for 4 of these records. 2) allow the user to output the name, salary, hire_date for a selected record 3) allow the user to change the name, salary, or hire_date for a selected record. 4) allow the user to input a complete record to replace one of the...

  • Write the program WritePatientRecords that allows a doctor’s staff to enter data about patients and saves...

    Write the program WritePatientRecords that allows a doctor’s staff to enter data about patients and saves the data to a file called Patients.txt. The output should be in the following format: p#, PATIENT_NAME, BALANCE. Create a Patient class that contains fields for ID number, name, and current balance owed to the doctor’s office. Save the contents of your output file as you will use them in the subsequent labs. An example of the program is shown below: Enter patient ID...

  • use at least two functions in your program. . Write a program that calculates weekly payment....

    use at least two functions in your program. . Write a program that calculates weekly payment. The program will ask the user full name, ID number (make one up), and hours worked. An hourly worker’s gross pay is basically his/her work hours that week multiplied by his/her regular hourly pay rate. However, after the first 40 work hours of the week, each additional work hour is paid at an overtime rate that is 1.5 times of the regular hourly rate....

  • Write a program call FancyMyName which as the user for their first and last name and...

    Write a program call FancyMyName which as the user for their first and last name and print it like the example output bellow: Please enter your first name and last name, separated by a space? You entered the name: Louis Henry Output: LoUiS HeNrY (Code needed in Java) Thank You.

  • == Programming Assignment == For this assignment you will write a program that reads in the...

    == Programming Assignment == For this assignment you will write a program that reads in the family data for the Martian colonies and stores that data in an accessible database. This database allows for a user to look up a family and its immediate friends. The program should store the data in a hashtable to ensure quick access time. The objective of this assignment is to learn how to implement and use a hashtable. Since this is the objective, you...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT