└── sum of range /sum of range: -------------------------------------------------------------------------------- 1 | Riya wants to find the sum of range values. could you please help her to implements the program. 2 | 3 | Input Format 4 | 5 | input consists of two integer 6 | Constraints 7 | 8 | No Constraints 9 | 10 | Output Format 11 | 12 | print the sum of range values. 13 | Sample Input 0 14 | 15 | 1 16 | 5 17 | Sample Output 0 18 | 19 | The sum of Range value from 1 to 5 is 15.0 20 | Sample Input 1 21 | 22 | 5 23 | 10 24 | Sample Output 1 25 | 26 | The sum of Range value from 5 to 10 is 45.0 27 | 28 | import java.io.*; 29 | import java.util.*; 30 | 31 | public class Solution { 32 | 33 | public static void main(String[] args) { 34 | Scanner sc=new Scanner(System.in); 35 | int n=sc.nextInt(); 36 | int s=sc.nextInt(); 37 | int sum=0; 38 | for(int i=n;i<=s;i++) 39 | { 40 | sum+=i; 41 | } 42 | System.out.println("The sum of Range value from " +n+ " to " +s+ " is " +sum+".0"); 43 | 44 | /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ 45 | } 46 | } 47 | --------------------------------------------------------------------------------