Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class vektor{
  4. public static void main(String[] args) {
  5. Scanner keyboard = new Scanner(System.in);
  6. double x, y, z, a;
  7.  
  8. System.out.println("Geben sie die x-Koordinate an:");
  9. x = keyboard.nextDouble();
  10. System.out.println("Geben sie die y-Koordinate an:");
  11. y = keyboard.nextDouble();
  12. System.out.println("Geben sie die z-Koordinate an:");
  13. z = keyboard.nextDouble();
  14.  
  15. // Betrag des Vektors
  16. a= Math.sqrt(x*x+y*y+z*z);
  17. System.out.println("Der Betrag des Vektors beträgt=" +a);
  18.  
  19. //Einheitsvektor??
  20. if (a==1) {
  21. System.out.println("Der angegebene Vektor ist ein Einheitsvektor.");
  22. } else {
  23. System.out.println("Der angegebene Vektor ist KEIN Einheitsvektor.");
  24. }
  25.  
  26. //Basisvektor??
  27. if (x==0 && y==0) {
  28. System.out.println("Der Vektor ist der Basisvektor in z-Richtung.");
  29. }
  30. if (z==0 && y==0) {
  31. System.out.println("Der Vektor ist der Basisvektor in x-Richtung.");
  32. }
  33. if (x==0 && z==0) {
  34. System.out.println("Der Vektor ist der Basisvektor in y-Richtung.");
  35. }
  36. if (x!=0 && y!=0 && z!=0) {
  37. System.out.println(" Es liegt kein Basisvektor vor.");
  38. } // end of if
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement