Question: Write a Java program takes a positive integer n as the first command line argument (that is, args [0]) and uses a for loop to

Write a Java program takes a positive integer n as the first command line argument (that is, args [0]) and uses a for loop to calculate the sum of 1.0/2*i for all odd integers i in the range 1 to n. Note: the fraction 1.0/2*i should be evaluated as a double to avoid integer division. If the value n is a non positive, print out an error message.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!