@@ -0,0 +1,1609 @@
+//Program to find dot/cross product of 3d vectors.%0Aimport java.util.*;%0A%0A%0Apublic class vectorDotCross %7B%0A%0A%09static void vInput(List%3CInteger%3E vect) %7B%0A%09%09System.out.println(%22Inputting a vector...%22);%0A%09%09Scanner input = new Scanner(System.in);%0A%09%09for (int i = 0; i%3C3; i++) %7B%0A%09%09int c = 1;c += i;%0A%09%09System.out.println(%22c%22 + c + %22:%22);%0A%09%09int comp = input.nextInt();%0A%09%09vect.add(comp);%0A%0A%09%7D%0A%0A%7D%0A%0A%0A%09public static void main(String%5B%5D args) %7B%0A%0A%09%09List%3CInteger%3E v1 = new ArrayList%3C%3E();%0A%09%09List%3CInteger%3E v2 = new ArrayList%3C%3E();%0A%09%09vInput(v1);%0A%09%09vInput(v2);%0A%09%09System.out.println(%22v1: %22 + v1);%0A%09%09System.out.println(%22v2: %22 + v2);%0A%09%09System.out.println(%22Do you want to find the dot product ('d/D') or cross product ('c/C') of the two vectors? %22);%0A%09%09%0A%09%09while (true) %7B%0A%09%09%0A%09%09//Takes in user_input of type char %0A%09%09Scanner user_input = new Scanner(System.in);%0A%09%09char uInput = user_input.next().charAt(0);%0A%0A%09%09if ((uInput == 'd') %7C%7C (uInput == 'D'))%7B%0A%09%09%09//Computing dot product%0A%09%09%09int dot = v1.get(0)*v2.get(0) + v1.get(1)*v2.get(1) + v1.get(2)*v2.get(2);%0A%09%09%09System.out.println(%22v1 . v2 = %22+ dot);%0A%09%09%09break;%0A%09%09%7D%0A%0A%09%09else if ((uInput == 'c') %7C%7C (uInput == 'C')) %7B%0A%09%09%09//Computing each component of cross product%0A%09%09%09int i = (v1.get(1)*v2.get(2) - v1.get(2)*v2.get(1));%0A%09%09%09int j = -(v1.get(0)*v2.get(2)-v1.get(2)*v2.get(0));%0A%09%09%09int k = (v1.get(0)*v2.get(1)-v1.get(1)*v2.get(0)); %0A%09%09%09List%3CInteger%3E v3 = new ArrayList%3C%3E();%0A%09%09%09v3.add(i); v3.add(j); v3.add(k); //Adding i,j,k components to v3%0A%09%09%09System.out.println(%22v1 x v2 = %22 + v3);%0A%09%09%09break;%0A%09%09%7D%0A%0A%09%09else %7B%0A%09%09%09System.out.println(%22You did not enter a valid input%5CnTry again%22);%0A%09%09%09continue;%0A%09%09%7D%0A%09%09%0A%7D%0A%09%09%0A%09%7D%0A%7D

Add files via upload