Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program to compute the following summation. sum(x)=(1+ 1 1+2 + 1 2+3 +...+ 1 n1+n if n 2 1 if n =1 n?

Write a program to compute the following summation. sum(x)=(1+ 1 1+2 + 1 2+3 +...+ 1 n1+n if n 2 1 if n =1 n? 1 The result: 1.0 n? 100 The result: 10.000000000000004

import java.util.Scanner; public class Summation { public static double sum(int n) { } public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("n? "); int n = input.nextInt(); double result = sum(n); System.out.println("The result:" + result); } } /* * Output */

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Marketing The Ultimate Marketing Tool

Authors: Edward L. Nash

1st Edition

0070460639, 978-0070460638

More Books

Students also viewed these Databases questions

Question

suppose you have the following table that consists of order quality

Answered: 1 week ago

Question

6. How do histories influence the process of identity formation?

Answered: 1 week ago