Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The question is to print the geometric progression, nth term and the sum in JAVA . All the things I have done, but the sum

The question is to print the geometric progression, nth term and the sum in JAVA. All the things I have done, but the sum is not coming right. The program is-

package abc; import java.util.Scanner; public class abc1 {

public static void main(String[] args) { // TODO Auto-generated method stub Scanner input = new Scanner(System.in);

System.out.print("Enter the value of a (First Term) : "); double firstTerm = input.nextDouble();

System.out.print("Enter the value of r (Common Ratio) : "); double commonRatio = input.nextDouble();

System.out.print("Enter the value of n (Number of terms) : "); double numberOfTerms = input.nextDouble();

double nthTerm = firstTerm * Math.pow(commonRatio, (numberOfTerms - 1));

double sum = (firstTerm * (Math.pow(commonRatio, numberOfTerms)-1)/ commonRatio-1) ; System.out.println("..."); System.out.println("The Geometric Progression is as follows :");

for(int i = 0; i

}

image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Find dy / dx y = x(x + 1) 1/3

Answered: 1 week ago

Question

4. Identify the challenges facing todays organizations

Answered: 1 week ago