• API
• FAQ
• Tools
• Archive
SHARE
TWEET # Task5 java proba Mary_99  Mar 21st, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import java.util.Scanner;
2. import java.util.*;
3.
5. {
6.
7.   public ScanningVectors(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 = " + '/n' + "");
12.         x1 = sc.nextInt();
13.         System.out.println("Enter y for vector 1 = " + '/n' + "");
14.         y1 = sc.nextInt();
15.
16.         System.out.println("Enter x for vector 2= " + '/n' + "");
17.         x2 sc.nextInt();
18.         System.out.println("Enter y for vector 2 = " + '/n' + "");
19.         y2 = sc.nextInt();
20.
21.         System.put.println("" + x1 + "" + y1 + "" + x2 + "" + y2);
22.   }
23.
24.
25.   public void AddingVectors(double vectorLength1; double vectorLength2)
26.   {
27.
28.     vectorLength1 = Math.sqrt(Math.pow(x1,2)+Math.pow(y1,2));
29.     vectorLength2 = Math.sqrt(Math.pow(x2,2)+Math.pow(y2,2));
30.
31.     if(vectorLength1 == vectorLength2)
32.     {
33.       double sum = vectorLength1 + vectorLength2;
34.       System.out.println("Sum of the vectors is equal to " + sum+'/n'+ "")
35.
36.     }else System.out.println("Vectors are not equal !!!" +'/n'+ "Please try again enter the vectors"+'/n'+"");
37.
38.   }
39.
40.
41.   public static void main(String[] args)
42.
43.     {
44.       ScanningVectors();
45.
46.
47.       }
48. }
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.     }
82. }
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