
Write a program using a for loop that computes the following sum:
1/2 + 2/2 + 3/2 + 4/2 + 5/2 + ... N/2
N will be an integer limit the user enters.
This is an example of my upcoming quiz. I need help on knowing the answer to this to be sure to pass my quiz.

import java.util.*;
class SumOfSeries
{
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
System.out.print("Enter the value of n: ");
int n=input.nextInt();
int sum=0;
//1/2 + 2/2 + 3/2 + 4/2 + 5/2 + ... N/2
for(int i=1;i<=n;i++){
sum+=i;
}
int sumOfSeries=1/2*(sum);
System.out.println("Sum of series: "+sum);
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.