Do 1.6, 1.7, 1.11
Every homework assignment should be done as a report. For each report you should include:
• 5 points: Your name
• 10 points: An assignment title
• 10 points: A single sentence that explains what you learned or noticed.
For every problem that you work through, you should include:
• 10 points: A single question describing what the question is asking
• 20 points: Your code
• 10 points: Your code output
• 10 points: A discussion of your solution
1.6
(Summation of a series) Write a program that displays the result of
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9.
1.7
(Approximate pi) pi can be computed using the following formula:
pi = 4 * (1 – 1/3 + 1/5 – 1/7 + 1/9 – 1/11 + …)
Write a program that displays the result of 4 * (1 – 1/3 + 1/5 – 1/7 + 1/9 – 1/11)
and 4 * (1 – 1/3 + 1/5 – 1/7 + 1/9 – 1/11 + 1/13).
Use 1.0 instead of 1 in your program.
1.11
(Population projection) The U.S. Census Bureau projects population based on the
following assumptions:
â– One birth every 7 seconds
â– One death every 13 seconds
â– One new immigrant every 45 seconds
Write a program to display the population for each of the next five years. Assume the
current population is 312,032,486 and one year has 365 days. Hint: In Java, if two
integers perform division, the result is an integer. The fractional part is truncated. For
example, 5 / 4 is 1 (not 1.25) and 10 / 4 is 2 (not 2.5). To get an accurate result with
the fractional part, one of the values involved in the division must be a number with a
decimal point. For example, 5.0 / 4 is 1.25 and 10 / 4.0 is 2.5.