Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Added: Dec 11, 2020 10:07 AM
Views: 3
Tags: methoden
  1. import java.util.Scanner;
  2. public class Main {
  3.     //Schreiben Sie ein Programm, das zur Eingabe eines Radius
  4.     //auffordert. Berechnen Sie dann den Umfang und den Flächeninhalt
  5.     //eines Kreises. Verwenden Sie Methoden:
  6.     public static void main(String[] args) {
  7.         var scan = new Scanner(System.in);
  8.         System.out.println("Umfang: " + calcScope(inputRadius(scan)));
  9.         System.out.println("Fläche: " + calcArea(inputRadius(scan)));
  10.     }
  11.     public static double inputRadius(java.util.Scanner scan) {
  12.         System.out.println("Bitte Radius eingeben.");
  13.         double radius = scan.nextDouble();
  14.         return radius;
  15.  
  16.     }
  17.  
  18.     public static double calcArea(double r){
  19.         double area = Math.PI*(Math.pow(r,2));
  20.  
  21.         return area;
  22.     }
  23.     public static double calcScope(double r){
  24.         double scope = 2*Math.PI*r;
  25.  
  26.         return scope;
  27.     }
  28. }