ITI 1120 Fall 2011 - Assignment 2

Available: Tue Sept 27
Due: Sat Oct 15, 22:00

Instructions

Instructions

This assignment is to be done individually. Please include your name and student number. Follow the instructions in the lab manual for submitting assignments through the Virtual campus. Question 1 should be answered in a Word file A2Q1.doc, and Question 2 in a file A2Q2.doc. Question 3 requires you to implement a Java program in a file A2Q3.java and compile it in A2Q3.class. Paste the content of the .java file into a file A2Q3.doc. Zip all the .doc files and the .java file and .class file in a2_xxxxxx.zip, where xxxxxx is your student number, and submit it through the Virtual Campus.

Your algorithms should be developed using the format. Your algorithm traces should use the format shown in class; a separate table is to be used for each call to each algorithm.

Marking Scheme (total 100 marks)

  • Regulations and Standards: 10 marks
  • Question 1: 10 marks
  • Question 2: 45 marks
  • Question 3: 35 marks

Question 1 (5 + 5 marks) Boolean expressions

Question 1a)  In this question, you should use the algorithm format for Boolean expressions.  Keep in mind the difference between a Boolean expression, and a test used in a branch or loop.  You need only to write the expression (example:  A (B + 3) ), and not a branch structure.

 

The Boolean expressions that you write for this question should use only the comparison operators (<, >, =, etc.), Boolean operators (AND, OR, NOT), and math operators +, , ×, /, or MOD.  Use parentheses where necessary. Do not use Java syntax!

 

Suppose that a variable L is true if an aircraft is in level flight, and false if the plane is in a landing or climbing phase. The landing gear should be lowered when both of the following conditions apply:

  • The aircraft is not in level flight and the aircraft speed S is less than 300, or the plane is in level flight and the speed is less than 200.
  • The altitude A of the aircraft is less than 1000; or if the altitude is less than 2000 and the speed of the plane S is less than 250.

Write a Boolean expression that is true if the aircraft landing gear should be lowered and false otherwise.

 


Question 1b)   In this question, you should use the Java format for Boolean expressions.  Keep in mind the difference between a Boolean expression, and a test used in an if statement.  You need only to write the expression (example:  A <= (B + 3) ), and not the complete if statement (you do not need to submit a Java program for this question).

 

The Java Boolean expressions that you write for this question should use only the comparison operators (<, >, ==, etc.), logical operators (&&, ||, !), and math operators +, , *, /, or % (modulo). Use parentheses where necessary.

 

Write a Boolean expression (Java) that is TRUE if the sum of three integers (A, B, C) is even and if the three numbers are all different from each other.

 

Question 2 (35 + 10 marks)

The federal income tax rates for 2011 are as follows [Source:  Canada Revenue Agency http://www.cra-arc.gc.ca/tx/ndvdls/fq/txrts-eng.html ]

  • 15% on the first $41,544 of taxable income (incl.), +
  • 22% on the next $41,544 of taxable income (on the portion of taxable income between $41544 (excl.) and $83,088 (incl.)), +
  • 26% on the next $45,712  of taxable income (on the portion of taxable income between $83,088 (excl.) and $128,800 (incl.)), +
  • 29% of taxable income over $128,800.

The chart below reproduces the calculation to calculate net federal tax.

 

On top of the federal tax, you need to add the provincial tax (for Ontario).

The provincial tax rates for Ontario are calculated as indicated below.

 

Provincial / Territorial tax rates (combined chart)

Provinces/ Territories

Rates

Ontario

5.05% on the first $37,774 of taxable income (incl.), +
9.15% on the next $37,776, +
11.16% on the amount over $75,550

 

Question 2a)  Design an algorithm that calculates the total tax (federal + provincial) for a specified taxable income of a resident of Ontario.

Question 1b) Trace your algorithm in part a), for a taxable income of $90,000. You can trace with other values too, for yourself.

 

Question 3 (35 marks)

Implement in Java your algorithm from Question 2a). Implement the algorithm as a Java method, and also implement a main method that asks the user to input his/her income, calls the algorithm, and displays a message with the result. Test your program for yourself.