Write a program that asks the user to input the first two terms of the sequence and then prints out the 50th term.
1
Expert's answer
2016-02-16T03:05:41-0500
import java.util.Scanner;
class Solution { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); double first = scanner.nextDouble(); double second = scanner.nextDouble();
//Series was not specified in the question, so I wrote solutions for two possible interpretations
{//If the series is a geometric progression if(first == 0){ System.out.println("First term is supposed not to be 0"); return; } double q = second/first; double res = first * Math.pow(q, 49); System.out.println(res); }
{//If the series is a arithmetic progression double d = second-first; double res = first + 49*d; System.out.println(res); } } }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments
Leave a comment