-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProgression.java
27 lines (25 loc) · 1 KB
/
Progression.java
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
import java.util.Scanner;
public class Progression
{
public static void main(String [] args)
{
Scanner keyboard = new Scanner (System.in);
System.out.println(
"This program will calculate the geometric and ");
System.out.println(
"harmonic progression for the number you enter.");
System.out.print(
"Enter an integer that is greater than or equal to 1: ");
int input = keyboard.nextInt();
int geomAnswer = geometricRecursive (input);
double harmAnswer = harmonicRecursive (input);
System.out.println("Using recursion:");
System.out.println("The geometric progression of " + input + " is " + geomAnswer);
System.out.println("The harmonic progression of " + input + " is " + harmAnswer);
geomAnswer = geometricIterative (input);
harmAnswer = harmonicIterative (input);
System.out.println("Using iteration:");
System.out.println("The geometric progression of " + input + " is " + geomAnswer);
System.out.println("The harmonic progression of " + input + " is " + harmAnswer);
}
}