Pascal Program Tutorial Sheet Tutorial Sheet c Question 8

Document Sample
Pascal Program Tutorial Sheet Tutorial Sheet c Question 8 Powered By Docstoc
					Under a certain income tax system, taxation is computed according to the following:

         Income Range                                 Taxation
    Below $200,000                NO TAX
    Between $200,000              20% of the excess income above $200,000
    More than $400,000            $40,000 plus 40% of the excess income above
                                  $400,000

   Write a structured algorithm to read the names and incomes of 15 persons, and to
   compute their income taxes. For each person, the algorithm must print the name
   of the person alongside his or her tax figure.
                                          CXC 2002 Specimen Quest. 10 (10 marks)

ALGORITHM – SOLUTION 1

Count = 1
Tax1 = .20
Tax2 = .40

WHILE Count <=16 DO

Read Name, Income
       IF Income <200 000 THEN
       Tax: = 0
       ELSE
              IF Income < 400 000 THEN
              Tax:= Tax1 * (Income – 200 000)
              ELSE
                     IF Income >= 400 000 THEN
                     Tax: = Tax2 * (Income – 400 000) + 40 000
                     ELSE
                     ENDIF
              ENDIF
       ENDIF
       Print Name, Tax
Count := Count + 1
ENDWHILE
Print “Number of Workers exceeds 15”

END
                                PASAL PROGRAM SOLUTIONS
PROGRAM CalculateSalary (Input, Output);

VAR Count: Real;
    Tax1, Tax2, Income: Integer;
    Name: Char [35];

Count = 1
Tax1 = .20
Tax2 = .40

BEGIN

WHILE Count <=15 DO

Write („Enter name of worker‟);
Readln (Name);
Write („Enter the salary earned‟);
Readln (Income);

             IF Income <200 000 THEN
             Tax: = 0
             ELSE
                    IF Income < 400 000 THEN
                    Tax:= Tax1 * (Income – 200 000)
                    ELSE
                           IF Income >= 400 000 THEN
                           Tax: = Tax2 * (Income – 400 000) + 40 000
                           ELSE
                           ENDIF;
                    ENDIF;
             ENDIF;
             Writeln („Name of worker and their tax amount is “, Name, Tax);

    Count := Count + 1;
ENDWHILE;

Write („Number of Workers exceeds 15‟);

END.



Pascal Code may contain some errors.

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:6
posted:12/4/2011
language:English
pages:2