CS 107 - Lab 3

Boolean Expressions

A Boolean expression results in a Boolean value. A Boolean value can have one of two values: true or false. There is also a Boolean data type where you can store a Boolean value in a variable. The C++ keyword for a Boolean type is bool.

Boolean expressions are used in a program to decide if something should or should not be done. There are two main sets of operators that work with Boolean expressions:

The relational operators take two values and evaluate to true or false based on the relation of the two values. There are six relational operators.
NameSymbolC++ ExampleMeaning
Equal to==val1 == 10true if val1 is equal to 10, false otherwise
Not equal to!=val1 != 10true if val1 is not equal to 10, false otherwise
Greater than>val1 > 10true if val1 is greater than 10, false otherwise
Greater than or equal to>=val1 >= 10true if val1 is greater than or equal to 10, false otherwise
Less than<val1 < 10true if val1 is less than 10, false otherwise
Less than or equal to<=val1 <= 10true if val1 is less than or equal to 10, false otherwise

The Boolean operators take two Boolean values and evaluates to ture or false based on the definition of the operator. There are three Boolean operators.

Selection Statements

The primary selection statement is an IF statement. The IF statement can have a number of different forms. We will discuss three of them here: the IF-THEN statement, the IF-THEN-ELSE statement and the NESTED-IF statement.

Lab Assignment

Due: By your Lab Time during the fourth week of the semester (the week of 2/3/2003).

You may turn in the assignment to your TA during lab or place it in his mailbox in 905 SEO. It is suggested that you place it in his mailbox just in case you are unable to attend lab. Hand in a print out of your program to do the folliwng to your TA.

Create a c++ program on your UIC icarus account that will calculate the income taxes owed based on the following table.
Income RangeIncome Tax Amount
$0 - $2,000Nothing
$2,001 - $20,0004% * Each dollar earned over $2,000
$20,001 - $40,000$720 + 8% * Each dollar earned over $20,000
$40,001 - $80,000$2,320 + 16% * Each dollar earned over $20,000
$80,001 - $120,000$8,720 + 24% * Each dollar earned over $20,000
$120,001 + $18,320 + 32% * Each dollar earned over $20,000
Your program is to prompt the user for their income amount and then read in this value from the input. Next your program should calcuate and output the the amount of income tax. Be sure to output your information is some readable style.

Hand in a print out of your program to your TA.