SHARE
TWEET

Untitled

a guest May 19th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package Fund;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Number {
  6.     public static void main(String[] args) {
  7.         Scanner sc = new Scanner(System.in);
  8.         int startNum = Integer.parseInt(sc.nextLine());
  9.         int endNum = Integer.parseInt(sc.nextLine());
  10.         int sum = 0;
  11.         String dig ="";
  12.         for (int i = startNum; i <= endNum; i++) {
  13.             dig += (i + " ");
  14.             sum += i;
  15.  
  16.         }
  17.         System.out.printf("%s %nSum: %d",dig,sum);
  18.     }
  19. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top