Math & Scanner Lab Worksheet

posted by: Mr. Bergquist 25 October 2011 No Comment

First, in Practice It! do these three Exercises:
(0: Optional Warm Up on Math Methods: Self-Check 3.10: mathExpressions )

  1. Exercise 3.3: printPowersOfN
  2. Exercise 3.8: quadratic
  3. Exercise 3.14: inputBirthday

Then do at least one of these three and have it manually checked off (highly recommend doing at least the first one!).  If you have more time, do all of them…

  1. Write a method placeCircles that has Scanner and Graphics parameters. Your method should prompt the user for a number of circles to draw then ask for information about each circle:
  2. If you ever find yourself buying a house, you’ll want to know what your monthly payment for the loan is going to be. Write a method that asks the user for information about a loan and prints the monthly payment.The formula for computing monthly mortgage payments involves the loan amount, the total number of months involved (a value we call n) and the monthly interest rate (a value we call c). The payment formula is given by the following equation:An example run of your program might produce the following output (user input is underlined):
    This program computes monthly loan payments.
    Loan amount? 275000
    Number of years? 30
    Interest rate? 6.75
    Your payment is $1783

    Note that the numbers being read as input don’t match the way they should be used in the formula. The term of the loan is read as years instead of months. The interest rate percentage is being read in as a yearly rate instead of a monthly rate and as a whole number rather than a true percentage, so the value 6.75 should actually become 0.005625 by dividing it by 12 and by 100. You will have to make these conversions as part of your program.

    Make sure the final printed results is in whole dollars, without any decimals!

  3. Write a program to produce beautiful square spirals! Your program should prompt the user for a window size and the distance between each arm of the spiral. See a sample run of the program:

(As always, big thanks to Ms. Martin for passing on these examples.)

1 Star2 Stars3 Stars4 Stars5 Stars (8 votes, average: 4.50 out of 5)
Loading ... Loading ...

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>