Advertisement
shlomibergic

assignment 8

May 29th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5. public static void main(String[] args) {
  6. Scanner s = new Scanner(System.in);
  7. int arr[][]=new int[3][5];
  8. System.out.println("please enter 5 numbr to arr #1 plus 5 to arr #2");
  9. for(int i=0; i<2; i++) // receiving data from user
  10. {
  11. for (int y = 0; y < 5; y++) {
  12. arr[i][y] = s.nextInt(); // entering data into arrays
  13. }
  14. }
  15. for(int i=0;i<5;i++)
  16. {
  17. arr[2][i]=arr[0][i]+ arr[1][i];// sum of arrays 1 and 2 to third array
  18. System.out.printf("%d \n",arr[2][i]);//printf the third array
  19. }
  20.  
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement