Extra Notes for Assignment 1 – Salary Tax Run the sample program –The program executable can only be executed on CSLINUX machines (linux platform only)

Slides:



Advertisements
Similar presentations
The Software Lifecycle. Example Problem: Update a Checkbook Write a program that allows the user to enter a starting balance, a transaction type, D or.
Advertisements

JAVA Coursework (the same for 2A and 2B). Fundamental Information The coursework is 30 marks in your O’Level = 15% of the exam Must be word processed.
Chapter 6 Modular Programming J. H. Wang ( 王正豪 ), Ph. D. Assistant Professor Dept. Computer Science and Information Engineering National Taipei University.
Chapter 7: User-Defined Functions II
Chapter 7: User-Defined Functions II Instructor: Mohammad Mojaddam.
Programming Types of Testing.
Starting Out with C++, 3 rd Edition 1 Chapter 1. Introduction to Computers and Programming.
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming The software development method algorithms.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 14 – Student Grades Application: Introducing.
Software Development Method. Assignments Due – Homework 0, Warmup Reading – Chapter 2 –
Problem Solving and Program Design. COMP104 Problem Solving / Slide 2 Our First Program // a simple program #include using namespace std; int main() {
Chapter 1: An Overview of Computers and Programming Languages
Chapter 6: User-Defined Functions I
Algorithms. Introduction Before writing a program: –Have a thorough understanding of the problem –Carefully plan an approach for solving it While writing.
1 Lab Session-III CSIT-120 Spring 2001 Revising Previous session Data input and output While loop Exercise Limits and Bounds GOTO SLIDE 13 Lab session.
Topic 4 – Programmer- Defined Functions. CISC 105 – Topic 4 Functions So far, we have only seen programs with one function, main. These programs begin.
PRE-PROGRAMMING PHASE
Chapter 1 Pseudocode & Flowcharts
Prof. R. Willingale Department of Physics and Astronomy 2nd Year C+R 2 nd Year C and R Workshop Part of module PA2930 – 2.5 credits Venue: Computer terminal.
The Project AH Computing. Functional Requirements  What the product must do!  Examples attractive welcome screen all options available as clickable.
Testing. What is Testing? Definition: exercising a program under controlled conditions and verifying the results Purpose is to detect program defects.
Chapter 6: User-Defined Functions I Instructor: Mohammad Mojaddam
สาขาวิชาเทคโนโลยี สารสนเทศ คณะเทคโนโลยีสารสนเทศ และการสื่อสาร.
INTRODUCTION TO ALGORITHMS PROGRAMMING. Objectives Give a definition of the term algorithm Describe the various parts of the pseudocode algorithm or algorithm.
Goals of Course Introduction to the programming language C Learn how to program Learn ‘good’ programming practices.
Chapter 2 Overview of C Part I J. H. Wang ( 王正豪 ), Ph. D. Assistant Professor Dept. Computer Science and Information Engineering National Taipei University.
CS 114 – Class 02 Topics  Computer programs  Using the compiler Assignments  Read pages for Thursday.  We will go to the lab on Thursday.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition, Fifth Edition Chapter 7: User-Defined Functions II.
More Algorithm Design CSIS 1595: Fundamentals of Programming and Problem Solving 1.
Topic 3 – The General Form of a C Program. CISC 105 – Topic 3 The General Form of a C Program Now, all of the basic building blocks of a C program are.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 6 Using Methods.
Chapter 1 Introduction Chapter 1 Introduction 1 st Semester 2015 CSC 1101 Computer Programming-1.
C++ Basics C++ is a high-level, general purpose, object-oriented programming language.
CS221 Algorithm Basics. What is an algorithm? An algorithm is a list of instructions that transform input information into a desired output. Each instruction.
Chapter 1 Pseudocode & Flowcharts
BMTRY 789 Lecture 10: SAS MACRO Facility Annie N. Simpson, MSc.
Computing Simulation in Orders Based Transparent Parallelizing Pavlenko Vitaliy Danilovich, Odessa National Polytechnic University Burdeinyi Viktor Viktorovych,
Chapter 3 Top-Down Design with Functions Part II J. H. Wang ( 王正豪 ), Ph. D. Assistant Professor Dept. Computer Science and Information Engineering National.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 6: User-Defined Functions I.
Chapter 3: User-Defined Functions I
The Hashemite University Computer Engineering Department
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 6: User-Defined Functions I.
1 Project 2: Using Variables and Expressions. 222 Project 2 Overview For this project you will work with three programs Circle Paint Ideal_Weight What.
1 UMBC CMSC 104, Section Fall 2002 Functions, Part 1 of 3 Topics Top-down Design The Function Concept Using Predefined Functions Programmer-Defined.
© Peter Andreae Java Programs COMP 102 # T1 Peter Andreae Computer Science Victoria University of Wellington.
Building Programs from Existing Information Solutions for programs often can be developed from previously solved problems. Data requirements and solution.
Evolution of C and C++ n C was developed by Dennis Ritchie at Bell Labs (early 1970s) as a systems programming language n C later evolved into a general-purpose.
CMSC 104, Section 301, Fall Lecture 18, 11/11/02 Functions, Part 1 of 3 Topics Using Predefined Functions Programmer-Defined Functions Using Input.
L071 Introduction to C Topics Compilation Using the gcc Compiler The Anatomy of a C Program Reading Sections
Dynamic SQL Writing Efficient Queries on the Fly ED POLLACK AUTOTASK CORPORATION DATABASE OPTIMIZATION ENGINEER.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 3 - Structured Program Development Outline.
CSC 1010 Programming for All Lecture 5 Functions Some material based on material from Marty Stepp, Instructor, University of Washington.
CCSA 221 Programming in C CHAPTER 3 COMPILING AND RUNNING YOUR FIRST PROGRAM 1 ALHANOUF ALAMR.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 3: Input/Output Samples.
Note: Some of the slides are repeated from Introduction to C++
Chapter 6: User-Defined Functions I
Chapter 7: User-Defined Functions II
Dynamic SQL Writing Efficient Queries on the Fly
Loops BIS1523 – Lecture 10.
Chapter 6 Modular Programming Dr. J.-Y. Pan Dept. Comm. Eng.
Topic: Functions – Part 2
Introduction to C Topics Compilation Using the gcc Compiler
Understand the Programming Process
User-Defined Functions
Understand the Programming Process
Chapter 6: User-Defined Functions I
Week 4 Lecture-2 Chapter 6 (Methods).
IPC144 Introduction to Programming Using C Week 4 – Lesson 2
Presentation transcript:

Extra Notes for Assignment 1 – Salary Tax Run the sample program –The program executable can only be executed on CSLINUX machines (linux platform only) –Download the program from the COMP1180 webpage and save it under your directory –Change to that directory (e.g. cd Documents) –Check the permission by typing “ls –l” –Change permission by typing “chmod 744 incometax” –Check the permission again by typing “ls –l” –Try running the program by typing “incometax” –Some good test cases are: –Can you see why the above are two good test cases?

Extra Notes for Assignment 1 – Salary Tax Your test plan –In each row, you specify a value for each of the following parameters for the program: Is_married Num_child Is_single_parent Spouse_disabled Num_brother_sister Num_parent_55_60 Num_parent_60plus –Specify 10 rows of input data and the input data set should be testing common cases as well as special cases. –The input data of is a good example to test for a single person, with no child, not single parent, no spouse, no dependent brother and sister, and no parents or grand parent at 55 or over.

Assignment 1 – Salary Tax Define the problem –Scope and generality of the solution needed –Input and Output Design a test plan –To verify your program is correct –Consist of a list of input data sets and correct program output –Consider all special cases Design a solution –Structured programming –Top down step refinement –Algorithm –Implementation –Testing and debugging

Assignment 1 – Salary Tax (continue) Define the problem –The specification is already listed in the Assignment1.doc –Goal: Calculate the salary tax for the year with the rate and allowance specified by the HK SAR Government. Two methods are used: 1) tax based on the defined tax brackets; 2) tax based on standard tax rate; There should be an indication when tax calculated by Method 2 is less than by Method 1. The amount of allowance should be printed out, together with 20 rows of output indicating how much tax should be paid according to the annual income starting from the Basic Allowance with an increment of $80, –Input: User have to answer some questions interactively (refer to the sample program) –Output: A table listing out the allowances claimed and a table listing out the salary tax based on Method 1 and Method 2 (refer to sample program)

Assignment 1 – Salary Tax (continue) Design a test plan –An input data set consists of the following 7 variables: Is_married Num_child Is_single_parent Spouse_disabled Num_brother_sister Num_parent_55_60 Num_parent_60plus –What will be some of the representative ones? –Why? –What are the expected output? –Assumption: The input data set is internally consistent. –For example, one cannot be a single parent with 0 child!

Assignment 1 – Salary Tax (continue) Design a solution –Structured Programming – Top Down Step Refinement –Outline in Pseudo-code: 1. Pre-Processor Commands 2. Declaration and initialization of variables 3. Enquiry (interactive inputs from user) 4. Processing 5. Printing results Program maintenance –Add in in-line comments –Add in blank lines for easier reading –Add in program and function headers –Programming style

Top Down Step Refinement 1. Pre-Processor Commands 1.1 Include necessary library(ies) 1.2 Define macros and constants 2. Declaration and initialization of variables 2.1 Declare variables 2.2 Initialize variables 3. Enquiry (interactive inputs from user) 3.1 Interact with the user to type in the 7 input data 3.2 Read input data and store them in the corresponding variables

More Step Refinement 4. Processing 4.1 Calculate the following allowance basic_allowance child_allowance single_parent_allowance brother_sister_allowance parent_gparent_allowance spouse_disabled_allowance 4.2 Calculate the total allowance 5. Printing results 5.1 Print out the amount of each kind of allowance 5.2 Print out the salary tax table

Yet Another Step Refinement 5.2 Print out the salary tax table Starting annual income = basic allowance For each annual income, calculate the salary tax by Method For each annual income, calculate the salary tax by Method In each row of output, print out the annual income, tax by Method 1, and tax by Method If Method 2 is less than Method 1, print an indicator Increment annual income by $80,000 and repeat Step to Step until 20 rows of output are printed.

Final Step Refinement & Implementation Calculate the salary tax by Method Calculate net chargeable income According to the net chargeable income, calculate the tax with: a) 2% for the 1 st $30,000; b) 8% for the next $30,000; c) 14% for the next $30,000; d) 20% for the rest of the balance; Implementation Replace the pseudo-code with C statements Testing and debugging Use the test plan for testing Edit, Save, Compile, and Run until passing the acceptance test