Positive or Negative Number Focus: if Statements Write a program

advertisement
Taxes
Focus: if, if else, scanner, boolean
Gilligan’s island is now charging it citizens an income tax each year. The tax rate is based upon the
following table:
Income $
0 – 5,000
5,001 – 10,000
10,001 – 20,000
20,001 – 40,000
over 40,000
Tax Rate %
0
3
5.5
10.8
23.7
Write a program which, given a person’s income, prints the tax owned rounded to the nearest dollar.
Positive or Negative Number
Focus: if Statements
Write a program that first declares a decimal number variable, then tests to see if that
number is positive, and prints out the value of the number, followed by “is a positive
number”, only if the number is positive.
For example, if the number was initialized to the value 5.42, then your program should
print “5.42 is a positive number”.
Nothing should be printed if the number is negative or zero. You should test to make sure
your program works properly by changing the value that you initialize the variable,
saving, compiling, and running your program each time you try a different value.
Make sure that the program works properly – just because the program runs, doesn’t
mean it is working properly. Check what is printed on the screen and ask yourself, does it
make sense?
Triangles
Focus: if, if else, scanner, boolean
Given the lengths of three sides of a triangle, print whether the triangle is scalene, isosceles, or
equilateral.
Download