Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////1
- package com.company;
- import java.util.Scanner;
- public class Main {
- static float root3(float x) {
- float y1 = x / 3;
- float y0 = 0;
- while (Math.abs(y0 - y1) > 1.0E-5) {
- y0 = y1;
- y1 = (2 * y0 + x / (y0 * y0)) / 3;
- }
- return y1;
- }
- public static void main(String[] arg) {
- Out.print("Zahl eingeben");
- float x;
- Scanner scan = new Scanner( System.in );
- x = scan.nextFloat();
- Out.println("Kubikwurzel von " + x + " ist " + root3(x));
- }
- }
- ////2
- package com.company;
- import java.util.Scanner;
- public class Aufgabe_2 {
- static double area(double a, double b, double c){
- double s = a + b + c / 2;
- return Math.sqrt(s * (s - a) * (s - b) * (s - c));
- }
- public static void main(String[] arg) {
- System.out.println("a:");
- double a;
- Scanner scan = new Scanner( System.in );
- a = scan.nextDouble();
- System.out.println("b:");
- double b;
- b = scan.nextDouble();
- System.out.println("c:");
- double c;
- c = scan.nextDouble();
- System.out.println("Die Fläche ist: " + area(a, b, c));
- }
- }
- ////3
- package com.company;
- import java.util.Scanner;
- public class Aufhabe_3 {
- public static void main(String args[]){
- String binärzahl;
- Scanner sc = new Scanner(System.in);
- System.out.println("Gib eine Binärzahl ein ");
- binärzahl = sc.nextLine();
- int decimal=Integer.parseInt(binärzahl,2);
- System.out.println(decimal);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement