IPT - A Virtual Approach IPT A Virtual Approach by Peter Whitehouse
Quick Links:
 
 
Information and Intelligent Systems Social and Ethical Implications Human Computer Interaction Software and Systems Engineering eXercise Files Course Outline and Assessment A-Z of Geeky Acronyms Terrace Work Program 2004 Sillybus FAQ = Frequently Asked Questions Help
 
 

eXercise #6

Multiple Branching using CASE

  1. Re-write the dice throwing program from the previous exercise set as a more efficient CASE statement.

  2. Write a simple program that accepts a character and reports what type of character it is based on the following ASCII classification:
    Characters Character Type
    ASCII 0-31,127 Control Characters
    'A' to 'Z' Alphabetic Uppercase
    'a' to 'z' Alphabetic Lowercase
    '0' to '9' Digits
    ASCII 128 to 255 Extended ASCII Graphics
    any others Punctuation


  3. Cutoffs are applied to cumulative achievement to determine your EXIT rating, and are typically:

    BETA

    • 80% or more = VHA
    • Between 79% and 65% = HA
    • Between 64% and 45% = SA
    • Between 44% and 25 = LA
    • Lower = VLA

    ALPHA
    • 70% or more = VHA
    • Between 69% and 55% = HA
    • Between 54% and 40% = SA
    • Between 39% and 25 = LA
    • Lower = VLA

    Write a program that accepts BOTH ALPHA and BETA percentage, and correctly outputs the EXIT rating, remembering that NO tradeoffs between ALPHA and BETA are allowed. (All percentages are rounded to the nearest whole)

  4. A person's initial taxation liability is determined on a formula which is based on their taxable income. This formula is:
    tax = base + rate x income
    Taxable incomes are divided into 'brackets', and for each so-called bracket, there is a different base and rate. For the purposes of this question, assume that these are:
    Bracket Base Rate
    below 4 000 0.00 0.00
    4 000 - 9 999 -760.00 0.19
    10 000 - 19 999 -2140.00 0.33
    20 000 - 29 999 -4960.00 0.47
    30 000 - 39 999 -7660.00 0.56
    40 000 and above -12060.00 0.67
    Write a program that accepts an amount of TAXABLE INCOME from the user, and correctly outputs the amount of TAX payable by them.

    Remember that the maximum integer available is 32 767 and that real expressions cannot be used as the basis of a case statement. However, a case statement should be used to locate the correct base and rate for the calculation.


Solutions

wonko@wonko.info
©Copyright t 1992..2018+. Edition 26.150117
wonkosite
Creative Commons License
This work is licensed under a
Creative Commons Attribution-NonCommercial-ShareAlike 2.1 Australia License
.