Results 1 to 2 of 2
- 10-30-2009, 11:53 PM #1
Member
- Join Date
- Sep 2009
- Posts
- 31
- Rep Power
- 0
Printing a table with a for loop help
hello, i am trying to write a program that displays the world population for present and the next 75 years based on its annual rate of increase (1.17). below is my code and its output. as you can see i am on the right track but i still cant figure out how to get the population to print next to the year, and also how to get it to repeat all the way down. any clues?
output:Java Code:public class WorldPopulation { public static void main(String[] args) { long pop=6816330827L; long population; double rate=1.17; {System.out.printf("%s%20s\n", "Year", "Population"); for (int year=1; year<=75; year++) System.out.println(year); population = (long)(pop*rate); System.out.println(population); } } }
Year Population
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
7975107067
-
Answer deleted due to the OP's multiposting the question.
OP: why did you repost this same question multiple times? This behavior mainly serve to alienate you from us. Is this your goal?Last edited by Fubarable; 10-31-2009 at 01:46 AM.
Similar Threads
-
Help in Printing
By kirly in forum Advanced JavaReplies: 3Last Post: 10-03-2011, 03:40 PM -
Printing a table with a for loop help
By shroomiin in forum New To JavaReplies: 2Last Post: 10-31-2009, 01:47 AM -
Problem printing inside FOR loop
By cassysumandak in forum New To JavaReplies: 1Last Post: 10-04-2009, 05:02 PM -
while-loop stopping on first loop
By davester in forum New To JavaReplies: 6Last Post: 06-26-2009, 08:46 PM -
Printing Example
By Java Tip in forum SWTReplies: 0Last Post: 07-11-2008, 04:41 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks