• Sign Up
• Login
• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# test

Mary_99 Mar 21st, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import java.util.Scanner;
2. import java.util.*;
3.
4. class Task5
5. {
6.
7.   public void Vectors(int x1, int y1, int x2, int y2)
8.   {
9.         Scanner sc = new Scanner(System.in);
10.
11.         System.out.println("Enter x for vector 1 = " );
12.         x1 = sc.nextInt();
13.         System.out.println("Enter y for vector 1 = " );
14.         y1 = sc.nextInt();
15.
16.         System.out.println("Enter x for vector 2 = ");
17.         x2 = sc.nextInt();
18.         System.out.println("Enter y for vector 2 = " );
19.         y2 = sc.nextInt();
20.
21.         System.out.println("" + x1 + "" + y1 + "" + x2 + "" + y2);
22.   }
23.
24.
25.   public void AddingVectors(double vectorLength1, double vectorLength2)
26.   {
27.     int x1, x2, y1, y2;
28.
29.     vectorLength1 = Math.sqrt(Math.pow(x1,2)+Math.pow(y1,2));
30.     vectorLength2 = Math.sqrt(Math.pow(x2,2)+Math.pow(y2,2));
31.
32.     if(vectorLength1 == vectorLength2)
33.     {
34.       double sum = vectorLength1 + vectorLength2;
35.       System.out.println("Sum of the vectors is equal to " + sum);
36.
37.     }else System.out.println("Vectors are not equal !!! Please try again enter the vectors");
38.
39.   }
40.
41.
42.   public static void main(String[] args)
43.
44.     {
45.
46.     Vectors(x1, x2, y1, y2);
47.
48.
49.       }
50. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!

Top