-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCh3Ex6.java
More file actions
36 lines (32 loc) · 737 Bytes
/
Ch3Ex6.java
File metadata and controls
36 lines (32 loc) · 737 Bytes
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
//Growth Rate Program using fibonacci
import java.util.Scanner;
public class Ch3Ex6
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
while (true)
{
System.out.println("Enter Population in pounds");
int startPop = input.nextInt();
System.out.println("Enter Number of Days");
int time = input.nextInt();
int pop = 0;
int prevPop = 0;
for (int i = 0;i<=time;i+=5)
{
pop = startPop + prevPop;
startPop = prevPop;
prevPop = pop;
}
System.out.println("New Population is: "+pop);
System.out.println("Enter 'exit' to quit or 0 to continue");
String loop = input.next();
if (loop.equals("exit"))
{
break;
}
}
input.close();
}
}