Create a class Geometric Series to model a Geometric series. Using friend function, overload the ~' operator to find the nth term of the series. Likewise, overload the T' operator (using a friend function) to find the sum of a Geometric series. Provide a function display() in the class to display the geometric series. Sample output of the program should be like the following.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

C++ PROGRAM

 

A geometric sequence is a sequence of numbers where each term after the first
is found by multiplying the previous one by a fixed, non - zero number
called the common ratio. For example, the sequences
2, 6, 18, ....
3, 15, 75, ..
are a geometric sequences with common ratios 3 and 5 respectively. A geometric
sequence is generally characterized by three numbers, the first term 'a', the
common ratio 'r' and the number of terms 'n’. A geometric series is the sum of
numbers in a geometric sequence. 2+ 6+ 18 and 3+ 15+ 75 are examples of geometric
series with three terms each.
The nth term of a geometric series with initial value 'a' and common ratio 'r
is given by: a, = arn-1, While the sum of a geometric series is given by:
a(1 – r")
1- rn
Create a class Geometric Series to model a Geometric series. Using friend function,
overload the * operator to find the nth term of the series. Likewise, overload
the P operator (using a friend function) to find the sum of a Geometric series.
Provide a function display() in the class to display the geometric series. Sample
output of the program should be like the following.
Sample Program
Output
GeometricSeries series (1,2,4);
Nth term is: 8
cout<<"Nth term is: "<<"series<<endl;
Sum of series is: 15
cout<<"Sum of series is:
The complete series
"<<!series<<endl; cout<<"The
complete series is: "<<endl;
series.display();
is: 1+2+4+8
Transcribed Image Text:A geometric sequence is a sequence of numbers where each term after the first is found by multiplying the previous one by a fixed, non - zero number called the common ratio. For example, the sequences 2, 6, 18, .... 3, 15, 75, .. are a geometric sequences with common ratios 3 and 5 respectively. A geometric sequence is generally characterized by three numbers, the first term 'a', the common ratio 'r' and the number of terms 'n’. A geometric series is the sum of numbers in a geometric sequence. 2+ 6+ 18 and 3+ 15+ 75 are examples of geometric series with three terms each. The nth term of a geometric series with initial value 'a' and common ratio 'r is given by: a, = arn-1, While the sum of a geometric series is given by: a(1 – r") 1- rn Create a class Geometric Series to model a Geometric series. Using friend function, overload the * operator to find the nth term of the series. Likewise, overload the P operator (using a friend function) to find the sum of a Geometric series. Provide a function display() in the class to display the geometric series. Sample output of the program should be like the following. Sample Program Output GeometricSeries series (1,2,4); Nth term is: 8 cout<<"Nth term is: "<<"series<<endl; Sum of series is: 15 cout<<"Sum of series is: The complete series "<<!series<<endl; cout<<"The complete series is: "<<endl; series.display(); is: 1+2+4+8
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Introduction to computer system
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education