info@meritcampus.com    +91-85006-22255
...

Write a program to complete the Geometric Series up to given number of terms.

Input (Fraction, Fraction, Integer) Output (List)
(1 / 1), (3 / 1), 17 [1/1, 3/1, 9/1, 27/1, 81/1, 243/1, 729/1, 2187/1, 6561/1, 19683/1, 59049/1, 177147/1, 531441/1, 1594323/1, 4782969/1, 14348907/1, 43046721/1]
(1 / 1), (-1 / 2), 16 [1/1, -1/2, 1/4, -1/8, 1/16, -1/32, 1/64, -1/128, 1/256, -1/512, 1/1024, -1/2048, 1/4096, -1/8192, 1/16384, -1/32768]
(1 / 9), (-1 / 27), 11 [1/9, -1/27, 1/81, -1/243, 1/729, -1/2187, 1/6561, -1/19683, 1/59049, -1/177147, 1/531441]
(4 / 3), (-1 / 1), 13 [4/3, -1/1, 3/4, -9/16, 27/64, -81/256, 243/1024, -729/4096, 2187/16384, -6561/65536, 19683/262144, -59049/1048576, 177147/4194304]
(5 / 1), (-10 / 1), 12 [5/1, -10/1, 20/1, -40/1, 80/1, -160/1, 320/1, -640/1, 1280/1, -2560/1, 5120/1, -10240/1]

``` class CompleteFractionalGeometricSeries {    public static void main(String s[])    {        Fraction first = new Fraction(3, 13);        Fraction second = new Fraction(6, 7);        List geometricSeries = completeTheGeometricSeries(first, second, 8);        System.out.println("The Geometric series " + geometricSeries);    } public static List<Fraction> completeTheGeometricSeries(Fraction firstNumber, Fraction secondNumber, int noOfTerms) { //Write the code here to complete the geometric series up to given number of terms. } //If required write the additional methods here. } class Fraction { int numerator; int denominator; public Fraction() { } public Fraction(int numerator, int denomenator) { this.numerator = numerator; denominator = denomenator; } @Override public String toString() { return numerator + "/" + denominator; } } ```

Topic: Java ArrayList

0
Wrong
Score more than 2 points