Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. ////1
  2. package com.company;
  3. import java.util.Scanner;
  4.  
  5.  
  6.  
  7. public class Main {
  8.  
  9. static float root3(float x) {
  10. float y1 = x / 3;
  11. float y0 = 0;
  12. while (Math.abs(y0 - y1) > 1.0E-5) {
  13. y0 = y1;
  14. y1 = (2 * y0 + x / (y0 * y0)) / 3;
  15. }
  16. return y1;
  17. }
  18.  
  19. public static void main(String[] arg) {
  20. Out.print("Zahl eingeben");
  21. float x;
  22. Scanner scan = new Scanner( System.in );
  23. x = scan.nextFloat();
  24. Out.println("Kubikwurzel von " + x + " ist " + root3(x));
  25. }
  26. }
  27. ////2
  28. package com.company;
  29. import java.util.Scanner;
  30.  
  31. public class Aufgabe_2 {
  32.  
  33. static double area(double a, double b, double c){
  34.  
  35. double s = a + b + c / 2;
  36. return Math.sqrt(s * (s - a) * (s - b) * (s - c));
  37. }
  38.  
  39. public static void main(String[] arg) {
  40.  
  41. System.out.println("a:");
  42. double a;
  43. Scanner scan = new Scanner( System.in );
  44. a = scan.nextDouble();
  45.  
  46. System.out.println("b:");
  47. double b;
  48. b = scan.nextDouble();
  49.  
  50. System.out.println("c:");
  51. double c;
  52. c = scan.nextDouble();
  53. System.out.println("Die Fläche ist: " + area(a, b, c));
  54. }
  55. }
  56. ////3
  57.  
  58. package com.company;
  59. import java.util.Scanner;
  60.  
  61. public class Aufhabe_3 {
  62.  
  63. public static void main(String args[]){
  64.  
  65.  
  66. String binärzahl;
  67. Scanner sc = new Scanner(System.in);
  68. System.out.println("Gib eine Binärzahl ein ");
  69. binärzahl = sc.nextLine();
  70.  
  71. int decimal=Integer.parseInt(binärzahl,2);
  72. System.out.println(decimal);
  73.  
  74. }
  75.  
  76.  
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement