|
@@ -8,10 +8,9 @@ import java.util.Scanner; |
|
|
public class CalSumOfGeo { |
|
|
public class CalSumOfGeo { |
|
|
public static void main(String[] args){ |
|
|
public static void main(String[] args){ |
|
|
double a, R, n; |
|
|
double a, R, n; |
|
|
|
|
|
double sumOfGeo; |
|
|
Scanner input = new Scanner(System.in); |
|
|
Scanner input = new Scanner(System.in); |
|
|
|
|
|
|
|
|
double sumofGS; |
|
|
|
|
|
|
|
|
|
|
|
System.out.print("Enter the first number of the sequence: "); |
|
|
System.out.print("Enter the first number of the sequence: "); |
|
|
a = input.nextDouble(); |
|
|
a = input.nextDouble(); |
|
|
|
|
|
|
|
@@ -21,10 +20,10 @@ public class CalSumOfGeo { |
|
|
System.out.print("Enter the number of the terms of the sequence: "); |
|
|
System.out.print("Enter the number of the terms of the sequence: "); |
|
|
n = input.nextDouble(); |
|
|
n = input.nextDouble(); |
|
|
|
|
|
|
|
|
sumofGS = (a*(Math.pow(R,n)-1))/(R-1); |
|
|
|
|
|
|
|
|
sumOfGeo = (a*(Math.pow(R,n)-1))/(R-1); |
|
|
|
|
|
|
|
|
System.out.print("The sum of Geometric Series: "); |
|
|
System.out.print("The sum of Geometric Series: "); |
|
|
System.out.printf("%1.1f\n" , sumofGS); |
|
|
|
|
|
|
|
|
System.out.printf("%1.1f\n" , sumOfGeo); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |