• 沒有找到結果。

Introduction to Computer Programming, 2005

N/A
N/A
Protected

Academic year: 2022

Share "Introduction to Computer Programming, 2005"

Copied!
2
0
0

加載中.... (立即查看全文)

全文

(1)

Introduction to Computer Programming, 2005

Program Assignment Ⅲ

2005/10/14

Scope: Chapter 3 & chapter 4 in Textbook (if, if…else, switch…case and for/while/do…while statement)

Notice:

1. Plagiarism is prohibited.

2. From program assignment 3, TA will randomly choose 10 students to demo program.

Problem: In Taiwan, people have to pay income tax to the government. Now, we use sliding scale tax as their tax formula. They have five scales to levy includes A, B, C, D and E, and the tax rates are 6%, 13%, 21%, 30%, 40%. You job is to design a calculator to calculate the amount of tax payable on a scale according to his/her net income. In sliding scale tax, if your net income is in tax scale C, your payable tax is 370,000 * 6% +(990,000 – 370,000) * 13% +(income – 990,000) * 21% . Please refer to the reference for detail information and explanations.

Deadline: 2005/10/28, 12:00 pm Hand-in:

1. Pack your program (HW3_STUDENTID.c) and document (HW3_STUDENTID.doc (or pdf)) into a compressed file (HW3_STUDENTID.rar (or zip))

2. In the document, you can explain how to achieve this program and use simple flow chart to show your program architecture. Also, you can show what kind of problems you met on developing this program and how to solve them. Notice, use one page to document your program.

3. Send the compressed file to cprog2005@csie.ntu.edu.tw with mail subject [cprog2005]HW3_STUDENTID

4. For example, if your student id is b94902200, the program file name is HW3_b94902200.c, the document file name is HW3_b94902200.doc and compressed file name is HW3_b94902200.rar.

Description:

1. In order to avoid overflow on the value of net income, you have to choose compatible data type.

(Hint. Check the range of int data type. Integer data type may not useful to store net income.) 2. You have to check an incredible income larger than 1,000,000,000.

3. If net income is -1, program is terminated.

4. Use while/do…while/for and break to iteratively ask user to input his/her net income and calculate the payable tax.

5. Use if…else to decide the tax scale (A, B, C, D, E).

6. According to the tax scale, use switch…case to choose the tax rate.

7. Use tax rate and income value to calculate the amount of payable tax.

(2)

Example Output:

Please input your net income of this year (-1 to terminate the program): 800000 The tax scale: B.

The tax rate: 13%.

The amount of tax payable on 800000: 78100

Please input your net income of this year (-1 to terminate the program): 100000000 Error: an incredible net income.

Please input your net income of this year (-1 to terminate the program): -1 Program is terminated.

Reference

1. Sliding scale tax

Income (X) Tax Rate Tax Scale Payable Tax

X <=370,000 6% A X * 6%

370,000 < X <= 990,000 13% B 22,200 + (X-370,000) * 13%

990,000 < X <= 1,980,000 21% C 102,800 + (X-990,000) * 21%

1,980,000 < X <= 3,720,000 30% D 310,700 + (X-1,980,000) * 30%

X > 3,720,000 40% E 832,700 + (X-3,720,000) * 40%

 If Dr. Milker’s net income is 1,980,000, his tax scale is C and tax rate is 21%.

The payable tax is

370,000 * 6% + (990,000 – 370,000) * 13% + (1,980,000 – 990,000) * 21%

= 102,800 + (1,980,000 – 990,000) * 21%

= 310,700.

 If Dr. Milker’s net income is 4,000,000, his tax scale is E and tax rate is 40%.

The payable tax is

370,000 * 6% + (990,000 – 370,000) * 13% + (1,980,000 – 990,000) * 21%

+ (3,720,000 – 1,980,000) * 30%+ (4,000,000 – 3,720,000) * 40%

= 832,700 + (4,000,000 – 3,720,000) * 40%

= 944,700

參考文獻

相關文件

(2) (20%) If your program can perform the add and print operations (but not move operations) correctly within the time limit, you get the score of this subtask. (3) (20%) If

In order to test your program, user can give the value of n to list Padovan sequence from P(0) to P(n) and corresponding accumulated triangle area.. The area of equilateral

Your job is to compute a score for each student given these two files, sort record by name, id, or grade, compute average score and standard deviation, and do some profile such

Using struct to maintain word database that consists word, word count, and occurrence (line number and the order in the line) called word database.. Using fixed array to store

In this homework, you are asked to implement k-d tree for the k = 1 case, and the data structure should support the operations of querying the nearest point, point insertion, and

Webots also contains a number of interfaces to real mobiles robots, so that once your simulated robot behaves as expected, you can transfer its control program to a real robot

You need to show your work to obtain

You need to act now plant it in your heart The simple fact of how we can do our part For future generations. Step up and make