Paste Search Dynamic
Recent pastes
sum of array
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. import java.util.Scanner;
  8. class Main {
  9.   public static void main(string[] args) {
  10.  
  11.          int i;
  12.      int[] arr1 = new int[5];
  13.      int[] arr2 = new int[10];
  14.  
  15.      int sum1 = 0;
  16.      int sum2 = 0;
  17.  
  18.      Scanner obj = new Scanner(system.in);
  19.  
  20.      system.out.println("enter numbers in array 1: ");
  21.  
  22.      for(i = 0; i < 5; i++){
  23.         arr1[i] = obj.nextInt();
  24.         sum1 = sum1 + arr1[i];
  25.           }
  26.  
  27.      system.out.println("enter numbers in array 2: ");
  28.  
  29.      for(i = 0; i < 10; i++){
  30.         arr2[i] = obj.nextInt();
  31.         sum2 = sum2 + arr2[i];
  32.           }
  33.  
  34.      system.out.println("sum of array 1 is: " + sum1 + "n and sum of array 2 is:" + sum2);
  35.  
  36.   }
  37. }
Parsed in 0.012 seconds