Programming Example: tax computation. Introduction In this webpage, we will study a programming example using the conditional statements (if and if-else)

Slides:



Advertisements
Similar presentations
C Programming Technique – Firdaus-Harun.com
Advertisements

Selection Statements Make a decision based on conditions Allows the computer to be intelligent.
If Statements, Try Catch and Validation. The main statement used in C# for making decisions depending on different conditions is called the If statement.
Knapsack Problem Section 7.6. Problem Suppose we have n items U={u 1,..u n }, that we would like to insert into a knapsack of size C. Each item u i has.
Copyright © 2014 McGraw-Hill Education. All rights reserved. No reproduction or distribution without the prior written consent of McGraw-Hill Education.
20.2 Simple Interest.
1 Federal Taxes. 2 Taxable Income and How Much You Owe – Your Tax Liability In the notes here I will show an example about the tax liability for a person.
Payroll Taxes & W-4s. Why do we pay taxes? Why do we pay taxes? Roads, Operation of Government, Schools, Welfare, Police, etc… Roads, Operation of Government,
Introduction to Flowcharting
Expanded Medicare taxes and other changes make planning critical Presented by: > [Insert your logo here] Health care act TAX OVERVIEW – INDIVIDUALS.
Tax filing information for international students.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Java Programming Practice.
INCOME PROPERTY ANALYSIS Introduction. INCOME PROPERTY ANALYSIS Acquisition Cash Flows.
Binary Decision Diagrams1 BINARY DECISION DIAGRAMS.
Old Colony Trust Co. v. Commissioner 279 U.S. 716 (1929)
International Students Who Had No U.S. Income in 2004.
PPA 419 – Aging Services Administration Lecture 4b – Program Characteristics of Social Security.
International Students Who Had No U.S. Income in 2007 Spring 2008.
LESSON 13-2 RECORDING EMPLOYER PAYROLL TAXES. Employee vs. Employer Taxes Employee Taxes ◦Federal Income Tax ◦Social Security Tax ◦Medicare Tax Employer.
Foreign Tax Credit. U.S. citizens and residents compute their U.S. taxes based on their worldwide income. This sometimes results in U.S. citizens having.
International Students & Scholars Who Had No U.S. Income in 2014 Spring 2015 Income Tax Workshop.
© Nuffield Foundation 2011 Nuffield Free-Standing Mathematics Activity Pay as you earn.
The break and continue statements. Introduction There are 2 special statements that can affect the execution of loop statements (such as a while-statement)
CSC103: Introduction to Computer and Programming
Copyright © 2015 by the McGraw-Hill Education. This is proprietary material solely for authorized instructor use. Not authorized for sale or distribution.
State Income Tax pp SECTION. Click to edit Master text styles Second level Third level Fourth level Fifth level 2 SECTION Copyright © Glencoe/McGraw-Hill.
Chapter 2, Sec. 2-2 Federal Income Taxes.
Verification and Conflicting Information Shannon Amundson, Cornell College.
Payroll Liabilities and Tax Records
Warm Up  0.04  ,700  2   0.05  ,200  6  Course Simple Interest 2,520 Thursday February 2,
Shafiqah Shariff 10C. 1. Your wage is $70,000 per annum from which you pay tax; calculate the tax to the nearest dollar... Tax Subdivision% Tax Payable.
Introduction to Algorithm Design and Documentation CSIS 1595: Fundamentals of Programming and Problem Solving 1.
Designing Programs with Branches CSIS 1595: Fundamentals of Programming and Problem Solving 1.
computer
Parameter passing mechanism: pass-by-value. Introduction In the last webpage, we discussed how to pass information to a method I have kept it (deliberately)
Introduction to Accounting Written by Ruby Ann Sawyer, Brantley County Middle School.
WRITTEN BY RUBY ANN SAWYER, BRANTLEY COUNTY MIDDLE SCHOOL Introduction to Accounting.
Formula? Unit?.  Formula ?  Unit?  Formula?  Unit?
In economics, Markets can be defined broadly or narrowly, depending on our purpose.
GOALS BUSINESS MATH© Thomson/South-WesternLesson 2.3Slide 1 2.3Federal Income Taxes Calculate adjusted gross income and taxable income Calculate the income.
Part 1 Intro: Working and Earning Goal: Describe the factors that influence an individual’s income. Brainstorm…… individual skills and abilities, work.
INCOME TAX. Income Tax  Self-assessment system  Taxpayers are responsible for reporting their own income and deductions.  Monitored by Canada Revenue.
Introduction to Accounting 8 th grade Mrs. Stovall.
1 Computer Science of Graphics and Games MONT 105S, Spring 2009 Session 3 Decision Trees Conditionals.
Section 2: Understanding what you make.  Explain my current (or future) paycheck.
Chapter 2 Excel Fundamentals Logical IF (Decision) Statements Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Glorian Portrait Studios Retained Earnings Statement For the Month ended May 31, 2007.
Introduction to Accounting. What is accounting? The system of recording and summarizing ______________ ___________and analyzing, verifying, and reporting.
Computer Science A 1. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated editor,
Taxes Gov’tForms Deductions.
Completing a W4 Form. How does an employer know how much taxes to withhold from your paycheck? A. They will withhold as much as possible B. You inform.
Find the percent of increase or decrease to the nearest percent. 1.) From 1 to ) From 162 to ) From 16 to 22 1 – = 38% D 177 – 162.
Lesson 4: Introduction to Control Statements 4.1 Additional Operators Extended Assignment Operators –The assignment operator can be combined with the.
Tax Timeline. When you first get hired… You fill out a what? – W-4 (Personal Allowances) – 4 first Why? – To help your employer figure the correct amount.
Bell Work Jan 28 1) 2) Obj: I will use percents to determine sales tax, tips, and commissions.
Unit-1 Introduction to Java
Chapter 3 Selections Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All rights reserved.
Selection Structures (Part 1)
the first card insert text here.
The method invocation mechanism and the System Stack
Computers & Programming Languages
Introduction to Algorithms
flow charts and system diagrams
Title of Study Presenter names Major department names
An Introduction to Linux
There many situations comes in real life when we need to make some decisions and based on these decisions, we decide what should we do next. Similar situations.
Introduction to OpenGL
Use yours to grow others!
4 Step Simple Diagram Sample text Sample text Sample text Sample text
4 Steps Thumbs Up Puzzle Diagram
Presentation transcript:

Programming Example: tax computation

Introduction In this webpage, we will study a programming example using the conditional statements (if and if-else) to write a Java program to compute the tax owed.

Formula to compute the tax owed Decision diagram to compute taxes owed:

Formula to compute the tax owed (cont.) Example 1: someone single earning $40,000 pays: 15% of $21,450, plus 28% of ($40,000 − $21,450)

Formula to compute the tax owed (cont.) Graphically:

Formula to compute the tax owed (cont.) Example 2: someone single earning $60,000 pays: 15% of $21,450, plus 28% of ($51,900 - $21,450), plus 31% of ($60,000 - $51,900)

Formula to compute the tax owed (cont.) Graphically:

Formula to compute the tax owed (cont.) Algorithm: Define the following constants: S1 = S2 = M1 = M2 = 86500

Formula to compute the tax owed (cont.) Structure diagram:

Formula to compute the tax owed (cont.) Example input: status = 'S' and income = 40000

Formula to compute the tax owed (cont.) The tax computation algorithm in Java: (The whole program is too large to show here). if ( status == 'S' ) { // ***** single if ( income <= S1 ) tax = RATE1 * income; else if ( income <= S2 ) tax = RATE1 * S1 + RATE2 * (income - S1); else tax = RATE1 * S1 + RATE2 * (S2 - S1) + RATE3 * (income - S2); }

Formula to compute the tax owed (cont.) else { // ***** married if ( income <= M1 ) tax = RATE1 * income; else if ( income <= M2 ) tax = RATE1 * M1 + RATE2 * (income - M1); else tax = RATE1 * M1 + RATE2 * (M2 - M1) + RATE3 * (income - M2); }

Formula to compute the tax owed (cont.) Constants used in the program:  RATE1 = 0.15 (Tax rate)  RATE2 = 0.28  RATE3 = 0.31  S1 = (Income brackets)  S2 =  M1 =  M2 = 86500

Formula to compute the tax owed (cont.) Java program: import java.util.Scanner; public class ComputeTax { public static void main(String[] args) { final double RATE1 = 0.15; // Tax rates final double RATE2 = 0.25; final double RATE3 = 0.31; final double S1 = ; // Tax brackets for single final double S2 = ; final double M1 = ; // Tax brackets for married final double M2 = ;

Formula to compute the tax owed (cont.) char status; double income = 0; double tax = 0; Scanner in = new Scanner(System.in); // Construct Scanner object System.out.print("Enter status (S or M) = "); status = in.next().charAt(0); // Read in status System.out.print("Enter income = "); income = in.nextDouble(); // Read in income >>>> Insert the Tax Computation Algorithm (see above) here <<<< System.out.println("Tax = " + tax); }

Formula to compute the tax owed (cont.) Programming advice: Using symbolic constants in computer program is highly recommended because when the tax rates or income brackets changes, we can easily accommodate the changes by changing the values of the constant definitions at the start of the program. We don't have to search for the constants inside the program !

Formula to compute the tax owed (cont.) Example Program: (The entire program is here) –Prog file: ComputeTax.java How to run the program: Right click on link and save in a scratch directory To compile: javac ComputeTax.java To run: java ComputeTax