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
Get step-by-step solutions from verified subject matter experts
