//Math.pow(R,n), R to the power of n //a * R to the power of n and divided by R - 1 package tutorial; import java.util.Scanner; public class CalSumOfGeo { public static void main(String[] args){ double a, R, n; double sumOfGeo; Scanner input = new Scanner(System.in); System.out.print("Enter the first number of the sequence: "); a = input.nextDouble(); System.out.print("Enter the common ratio of the sequence: "); R = input.nextDouble(); System.out.print("Enter the number of the terms of the sequence: "); n = input.nextDouble(); sumOfGeo = (a*(Math.pow(R,n)-1))/(R-1); System.out.print("The sum of Geometric Series: "); System.out.printf("%1.1f\n" , sumOfGeo); } }