subject

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;

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 02:00
For a typical middle-income family, what is the estimated cost of raising a child to the age of 18? $145,500 $245,340 $304,340 $455,500
Answers: 1
question
Computers and Technology, 23.06.2019 19:00
Write a program that displays the following menu: geometry calculator 1. calculate the area of a circle 2. calculate the area of a rectangle 3. calculate the area of a triangle 4. quit enter your choice (1-4): if the user enters 1, the program should ask for the radius of the circle and then display its area. use the following formula: area = ď€(the square of r) use 3.14159 for ď€ and the radius of the circle for r. if the user enters 2, the program should ask for the length and width of the rectangle and then display the rectangle’s area. use the following formula: area = length * width if the user enters 3, the program should ask for the length of the triangle’s base and its height, and then display its area. use the following formula: area = base * height * .5 if the user enters 4, the program should end. input validation: display an error message if the user enters a number outside the range of 1 through 4 when selecting an item from the menu. do not accept negative values for the circle’s radius, the rectangle’s length or width, or the triangle’s base or height. note: if the user enters an improper menu choice (1-4), the program prints "the valid choices are 1 through 4. run the program again and select one of those." if the user enters a negative radius, the program prints "the radius can not be less than zero." if the user enters a negative value for height or base, the program prints "only enter positive values for base and height."
Answers: 1
question
Computers and Technology, 24.06.2019 01:30
Could you find out how im still getting an 83 percent on this in edhesive a = input("enter an animal: ") s = input ("enter a sound: ") e = "e-i-e-i-o" print ("old macdonald had a farm, " + e) print ("and on his farm he had a " + a + "," + e) print ("with a " + s + "-" + s + " here and a " + s + "-" + s + " there") print ("here a " + s+ " there a " + s) print ("everywhere a " + s + "-" + s ) print ("old macdonald had a farm, " + e)
Answers: 2
question
Computers and Technology, 24.06.2019 09:30
Atype of researcher who uses computers to make sense of complex digital data
Answers: 1
You know the right answer?
We want to create a class that represents a geometric sequence. A geometric sequence is a sequence <...
Questions
question
Spanish, 22.04.2020 23:22
question
Mathematics, 22.04.2020 23:23
Questions on the website: 13722360