Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Kolo
- {
- public Kolo() {
- boolean run = true;
- while(run) {
- Scanner in = new Scanner(System.in);
- try {
- System.out.println("Podaj promień: ");
- double a = in.nextDouble();
- if(a<=0) {
- System.out.println("Promień nie może być mniejszy lub równy 0");
- }
- if(a > 0) {
- double c = 3.14;
- double d = c * Math.pow(a , 2);
- System.out.println("Pole twojego koła wynosi: " +d+ ".\n");
- double e = 2*c*a;
- System.out.println("Obwód twojego koła wynosi: "+e+".\n");
- }
- } catch (InputMismatchException e) {
- System.out.println("Tylko liczby!");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement