Available: Tue Sept 27
Due: Sat Oct 15, 22:00
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.
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:
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.
The federal income tax rates for 2011 are as follows
[Source:
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 |
|
|
5.05% on the first $37,774 of taxable income (incl.),
+ |
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.
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.