Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- public class PolaFigur {
- public static void main(String[] args) throws IOException {
- BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
- boolean nieZatrzymano = true;
- while (nieZatrzymano) {
- System.out.println("Co bedziesz liczyl? 0 - pole 1 - obwod");
- int coBedzieLiczone = Integer.parseInt(reader.readLine());
- System.out.println(coBedzieLiczone);
- System.out.println("Wybierz figure: ");
- System.out.println("0 - kwadrat");
- System.out.println("1 - trojkat");
- System.out.println("2 - prostokat");
- System.out.println("3 - trapez");
- int numerFigury = Integer.parseInt(reader.readLine());
- switch (numerFigury) {
- case 0: {
- switch (coBedzieLiczone) {
- case 0: {
- int a;
- System.out.println("Podaj bok kwadratu");
- a = Integer.parseInt(reader.readLine());
- double pole = a * a;
- System.out.println("Pole wynosi " + pole);
- break;
- }
- case 1: {
- int a;
- System.out.println("Podaj bok kwadratu");
- a = Integer.parseInt(reader.readLine());
- int obwod = 4 * a;
- System.out.println("obwod wynosi: " + obwod);
- break;
- }
- }
- break;
- }
- case 1: {
- switch (coBedzieLiczone) {
- case 0: {
- int a;
- int h;
- System.out.println("Podaj podstawe trojkata");
- a = Integer.parseInt(reader.readLine());
- System.out.println("Podaj wysokosc torjkata");
- h = Integer.parseInt(reader.readLine());
- double pole = a * h / 2;
- System.out.println("Pole wynosi " + pole);
- break;
- }
- case 1: {
- int a;
- int b;
- int c;
- System.out.println("Podaj bok a");
- a = Integer.parseInt(reader.readLine());
- System.out.println("Podaj bok b");
- b = Integer.parseInt(reader.readLine());
- System.out.println("Podaj bok c");
- c = Integer.parseInt(reader.readLine());
- int obwod = a + b + c;
- System.out.println("obwod wynosi: " + obwod);
- break;
- }
- }
- break;
- }
- case 2: {
- switch (coBedzieLiczone) {
- case 0: {
- int a;
- int b;
- System.out.println("Podaj bok a");
- a = Integer.parseInt(reader.readLine());
- System.out.println("Podaj bok b");
- b = Integer.parseInt(reader.readLine());
- double pole = a * b;
- System.out.println("Pole wynosi " + pole);
- break;
- }
- case 1: {
- int a;
- int b;
- System.out.println("Podaj bok a");
- a = Integer.parseInt(reader.readLine());
- System.out.println("Podaj bok b");
- b = Integer.parseInt(reader.readLine());
- int obwod = 2 * a + 2 * b;
- System.out.println("obwod wynosi: " + obwod);
- break;
- }
- }
- break;
- }
- case 3: {
- switch (coBedzieLiczone) {
- case 0: {
- int a;
- int b;
- int h;
- System.out.println("Podaj pierwsza podstawe trapezu");
- a = Integer.parseInt(reader.readLine());
- System.out.println("Podaj druga podstawe trapezu");
- b = Integer.parseInt(reader.readLine());
- System.out.println("Podaj wysokosc trapezu");
- h = Integer.parseInt(reader.readLine());
- double pole = (a + b) * h / 2;
- System.out.println("Pole wynosi " + pole);
- break;
- }
- case 1: {
- int a;
- int b;
- int c;
- int d;
- System.out.println("Podaj bok a");
- a = Integer.parseInt(reader.readLine());
- System.out.println("Podaj bok b");
- b = Integer.parseInt(reader.readLine());
- System.out.println("Podaj bok c");
- c = Integer.parseInt(reader.readLine());
- System.out.println("Podaj bok d");
- d = Integer.parseInt(reader.readLine());
- int obwod = a + b + c + d;
- System.out.println("obwod wynosi: " + obwod);
- break;
- }
- }
- break;
- }
- default: {
- break;
- }
- }
- System.out.println("Czy chcesz kontynuowac (0 - nie, 1 lub inna liczba - tak)");
- int czyKontynuowac = Integer.parseInt(reader.readLine());
- if (czyKontynuowac ==0) nieZatrzymano = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement