Running sum and average
You are given an integer n .Your task is to write a program to print the running sum from 1 to n and its average.
Input Format
For each test case, you will get n as an integer input.
Constraints
1<=n<=1000
Output Format
First line print the sum.
second line print its average.
Sample Input 0
5
Sample Output 0
15
3
Explanation 0
First line sum from 1 to 5 is 15.
Second line average is 3.
ALSO READ: Write a program to Print Vowels in String
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int sum=0;
for(int i=1; i<=n; i++){
sum+=i;
}
System.out.println(sum);
int avg=sum/n;
System.out.println(avg);
}
}