Computers and Technology

We want to create a class that represents a geometric sequence. A geometric sequence is a sequence
of numbers that begin at some value and then multiplies each value by some constant to get the next
value. For example, the geometric sequence 1, 2, 4, 8, 16 starts at 1 and multiplies each term by 2 to get
the next. The geometric sequence 10.8, 5.4, 2.7, 1.35 starts at 10.8 and multiplies each term by 0.5 to get
the next. The basic framework of a geometric sequence class is below:

public class GeometricSequence
{
private double initialValue;
private double multiplier;
}
We want to produce elements of the geometric sequence using codeSystem. out. println (first. next());
// Prints 1 and advances
System. out. println (first. next()); // Prints 2 and advances
System. out. println (first. next()); // Prints 4 and advances
System. out. println (first. next()); // Prints 8 and advances
System. out. println (second. next()); //Prints 10.8 and advances
System. out. println (second. next()); //Prints 5.4 and advances
System. out. println (second. next()); //Prints 2.7 and advances
What should the body of the next method be?

a) double result = initialValue;
initialValue = initialValue * multiplier;
return result;
b) return initialValue;
initialValue = initialValue * multiplier;
c) double result = initialValue;
multiplier = initialValue * multiplier;
return result;
d) initialValue = initialValue * multiplier;
return initialValue;

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 00:30, angeline2004
At an open or uncontrolled intersection, yield if a. the cross road has more lanes than yours b. the cross road has fewer land than yours c. you’re on a state highway and the cross road is a secondary road d. do you have three or more passengers in your vehicle
Answers: 2
image
Computers and Technology, 23.06.2019 15:20, yeahmaneee
What does a bonus object do? a. subtracts lives b. keeps track of a player's health c. gives a player an advantage d. makes text appear
Answers: 1
image
Computers and Technology, 23.06.2019 18:30, janny48
How often does colleges update the cost of attendance on their website? . a)every two years b) every four years c) every year d) every semester
Answers: 1
image
Computers and Technology, 23.06.2019 20:30, maryanapritchak1829
If chris has a car liability insurance, what damage would he be covered for
Answers: 1
Do you know the correct answer?
We want to create a class that represents a geometric sequence. A geometric sequence is a sequence <...

Questions in other subjects:

Konu
Mathematics, 22.11.2021 07:10
Konu
SAT, 22.11.2021 07:20