Created
July 2, 2020 09:09
-
-
Save KaratekHD/34978cd1b2cb98c24ce1d6c73f71af9a to your computer and use it in GitHub Desktop.
Kleines Programm um Flächeninhalt und Umfang von Kreisen zu berrechnen
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.karatek.randomstuff.math; | |
public class Kreise { | |
public static void main(String[] args) { | |
// Aufgabe Wert Einheit | |
System.out.println("Aufgabe " + args[0]); | |
System.out.println(); | |
area(Double.valueOf(args[1]), args[2]); | |
System.out.println(); | |
extent(Double.valueOf(args[1]), args[2]); | |
System.out.println("\n"); | |
} | |
public static void area(double r, String unit) { | |
System.out.println("r = " + r + unit); | |
double A = Math.PI * r * r; | |
System.out.println("A = π * r * r"); | |
System.out.println("A = π * " + r + " * " + r); | |
A = A * 100; | |
A = Math.round(A); | |
A = A / 100; | |
System.out.println("A = " + A + unit); | |
} | |
public static void extent(double r, String unit) { | |
System.out.println("r = " + r + unit); | |
double u = 2 * Math.PI * r; | |
System.out.println("u = 2 * π * r"); | |
System.out.println("u = 2 * π * " + r); | |
u = u * 100; | |
u = Math.round(u); | |
u = u / 100; | |
System.out.println("u = " + u + unit); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment