From a986fdc0ffde5451c365f7c124a99a37300f2e1c Mon Sep 17 00:00:00 2001 From: tenas97 Date: Tue, 8 Aug 2017 12:25:25 +0100 Subject: [PATCH] First Epc assignment --- Ryan/src/AddMatrices.java | 48 +++++++++++++++++++++++ Ryan/src/Arrayz.java | 76 +++++++++++++++++++++++++++++++++++++ Ryan/src/ArrayzTest.java | 26 +++++++++++++ Ryan/src/ReplaceLetter.java | 24 ++++++++++++ 4 files changed, 174 insertions(+) create mode 100644 Ryan/src/AddMatrices.java create mode 100644 Ryan/src/Arrayz.java create mode 100644 Ryan/src/ArrayzTest.java create mode 100644 Ryan/src/ReplaceLetter.java diff --git a/Ryan/src/AddMatrices.java b/Ryan/src/AddMatrices.java new file mode 100644 index 0000000..f945d18 --- /dev/null +++ b/Ryan/src/AddMatrices.java @@ -0,0 +1,48 @@ +/** + * Created by tenas on 8/3/17. + */ +import java.util.Scanner; + +public class AddMatrices { + public static void main(String args[]) + { + int m, n, c, d; + Scanner in = new Scanner(System.in); + + System.out.println("Enter the number of rows and columns of matrix"); + m = in.nextInt(); + n = in.nextInt(); + + int first[][] = new int[m][n]; + int second[][] = new int[m][n]; + int sum[][] = new int[m][n]; + + System.out.println("Enter the elements of first matrix"); + + for ( c = 0 ; c < m ; c++ ) + for ( d = 0 ; d < n ; d++ ) + first[c][d] = in.nextInt(); + + System.out.println("Enter the elements of second matrix"); + + for ( c = 0 ; c < m ; c++ ) + for ( d = 0 ; d < n ; d++ ) + second[c][d] = in.nextInt(); + + for ( c = 0 ; c < m ; c++ ) + for ( d = 0 ; d < n ; d++ ) + sum[c][d] = first[c][d] + second[c][d]; //replace '+' with '-' to subtract matrices + + System.out.println("Sum of entered matrices:-"); + + for ( c = 0 ; c < m ; c++ ) + { + for ( d = 0 ; d < n ; d++ ) + System.out.print(sum[c][d]+"\t"); + + System.out.println(); + } + } +} + + diff --git a/Ryan/src/Arrayz.java b/Ryan/src/Arrayz.java new file mode 100644 index 0000000..c3199db --- /dev/null +++ b/Ryan/src/Arrayz.java @@ -0,0 +1,76 @@ +import java.util.ArrayList; +import java.util.Random; + +/* + Created by tenas on 8/3/17. + */ +public class Arrayz { + + private int[] a; + + public Arrayz(int[] a) { + this.a = a; + } + + public int[] getA() { + return a; + } + + public void reverseArray(int[] b) { + int temporal; + for(int i=0; imax) { + max = a; + } + } + for(int a: d){ + if(a commonElements = new ArrayList<>(); + int counter = 0; + for(int i=0; i