gram calculates the geometric and harmonic progression for a number entered by the user. */ public class Progression {
import java.util.Scanner;
/**
This
harmonic progression for a number entered
by the user.
*/
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 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();
// Match the method calls with the methods you write
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);
// Match the method calls with the methods you write
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);
}
// ADD LINES FOR TASK #2 HERE
// Write the geometricRecursive method
// Write the geometricIterative method
// Write the harmonicRecursive method
// Write the harmonicIterative method
}
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 5 images