Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package twentybiteen;
- import java.util.Scanner;
- public class MathArray {
- static Scanner sc = new Scanner(System.in);
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Math();
- }
- public static void Math() {
- System.out.println("How long do you want the array to be?");
- int size = sc.nextInt();
- double[] a = new double[size];
- double[] b = new double[size];
- double[] sum = new double[size];
- double[] difference = new double[size];
- double[] quotient = new double[size];
- System.out.println("Enter " + size + " value(s) for the first array.");
- for (int i = 0; i < size; i++) {
- a[i] = sc.nextDouble();
- }
- System.out.println("Enter " + size + " value(s) for the second array.");
- for (int i = 0; i < size; i++) {
- b[i] = sc.nextDouble();
- }
- System.out.println("This is the sum of both arrays.");
- for (int i = 0; i < size; i++) {
- sum[i] = a[i] + b[i];
- System.out.println(sum[i]);
- }
- System.out.println("This is the different of both arrays.");
- for (int i = 0; i < size; i++) {
- difference[i] = a[i] - b[i];
- System.out.println(difference[i]);
- }
- System.out.println("This is the different of both arrays.");
- for (int i = 0; i < size; i++) {
- quotient[i] = a[i] / b[i];
- System.out.println(quotient[i]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement