- Jun 18, 2004
- 101
- 0
- 0
Geez, I hate this self-teaching book. Can someone show me how to do the following problems in Java and also recommend a good self-teaching book that actually explains the concepts with a lot of examples. Thx.
1. The population of Mexico in 1990 as 89.2 million. Write a program that calculates and prints out the year in which the population of Mexico will reach 120 million, assuming a constant growth rate of 2.3% per year. Use a While loop to accomplish this task.
2. Write a program with a method int addOdds(int n) that calculates and returns the sum of all odd integers from 1 to n. Your method should use exactly one ?for? loop and no other iterative statements. (Do not use the formula for the sum of odd numbers).
1. The population of Mexico in 1990 as 89.2 million. Write a program that calculates and prints out the year in which the population of Mexico will reach 120 million, assuming a constant growth rate of 2.3% per year. Use a While loop to accomplish this task.
2. Write a program with a method int addOdds(int n) that calculates and returns the sum of all odd integers from 1 to n. Your method should use exactly one ?for? loop and no other iterative statements. (Do not use the formula for the sum of odd numbers).