Question: Write a class that asks for a whole number `num` make sure it is greater than `0` (data validation), and that calculates and returns the sum of the following series of numbers:

```
1/num + 2/num-1 + 3/num-2 + …. (num-1)/2 + num/1

```

Don't get caught in integer division!

Test your method by invoking it with `num = 2;` you will expect the result to be `2.5`.

```
    public class LengthSeries
{
    public static void main (String[] args)
    {
    //variable declarations
    Scanner keyboard =  new Scanner(System.in);
    int num;
    int sum = 0; // sum
    int ctr = 1 ; //counter

    //Accept the required data

    System.out.print ("Enter a whole number greater than 0 :  ");
    num = keyboard.nextInt();

    //Process the data in order to determine data
    while ( num <= 0){
                     System.out.println ("Sorry number invalid");
                     System.out.println ("please write a whole number greater than 0 :  ");
                     num = keyboard.nextInt();
                  }

    while (num <= 0){  

                    sum += (ctr / num);
                    num -= ctr;
                    ctr++;
                } 

    //Display the output
    System.out.println ();
    System.out.println ("Your sum is:  "         +sum);
    System.out.println ("\n\nWritten by: KinnahRose Lopez");

    } //end main method
} //end LengthSeries class

```

Answer: 
```
import java.util.Scanner;`enter code here`
public class Test
{
    public static void main (String[] args)
    {
        //variable declarations
        Scanner keyboard =  new Scanner(System.in);
        int num;
        double sum = 0; // sum
        //Accept the required data
        System.out.print ("Enter a whole number greater than 0 :  ");
        num = keyboard.nextInt();
        //Process the data in order to determine data
        while ( num <= 0){
            System.out.println ("Sorry number invalid");
            System.out.println ("please write a whole number greater than 0 :  ");
            num = keyboard.nextInt();
        }
        int temp = num;
        for (double i = 1; i <= num; i++) 
        {
            sum = sum + (i/temp);
            temp--;
        } 
        //Display the output
        System.out.println ();
        System.out.println ("Your sum is:  "         +sum);
        System.out.println ("\n\nWritten by: KinnahRose Lopez");

    } //end main method
} //end LengthSeries class

```
```
double sum =0;
for(double i=1.0; i<= num; i+=1.0) {
    sum+=i/(num-i-1);
}

```