Java - Piszemy prosty kalkulator [Java od podstaw 24/41]

Поделиться
HTML-код
  • Опубликовано: 21 окт 2024
  • 🔥 Dołącz do bezpłatnego mailingu i ucz się programowania w Javie: javaodpodstaw.... 🔥
    🔥 Dołącz do kursu Java od podstaw: javaodpodstaw.pl/ 🔥
    ✉️ Kontakt: kamil@jaknauczycsieprogramowania.pl

Комментарии • 4

  • @Mr._404_guy
    @Mr._404_guy 4 месяца назад +1

    Rozwiązałem to trochę bardziej topornie:
    import java.util.Scanner;
    public class Main
    {
    public static void main(String[] args)
    {
    Scanner Numbers = new Scanner(System.in);
    System.out.println();
    System.out.println("Type first number:");
    byte a = Numbers.nextByte();
    System.out.println();
    System.out.println("Type second number:");
    byte b = Numbers.nextByte();
    int c = a + b;
    int d = a - b;
    int e = a * b;
    int f = a / b;
    int g = a % b;
    System.out.println("Result of addition is: " + c);
    System.out.println("Result of subtraction is: " + d);
    System.out.println("Result od multiplication is: " + e);
    System.out.println("Result of Division is: " + f);
    System.out.println("Rest is: " + g);
    }
    }

  • @endi-km
    @endi-km 2 месяца назад +1

    Ja to rozwiązałem podobnie, ale patrząc na komentarze widać jak na wiele sposobów można to rozwiązać.
    import java.util.Scanner;
    public class Main {
    public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    System.out.println("Podaj pierwszą liczbę:");
    int a = scanner.nextInt();
    System.out.println("Podaj drugą liczbę:");
    int b = scanner.nextInt();
    System.out.println("
    " + "Wynik dodawania to " + (a + b) + "
    " + "Wynik odejmowania to " + (a - b) + "
    " + "Wynik mnożenia to " + (a * b) + "
    " + "Wynik dzielenia to " + (a / b));
    }
    }

  • @oliwerniewiarowski
    @oliwerniewiarowski 5 месяцев назад +1

    import java.util.Scanner;
    class Scratch {
    public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    System.out.println("Podaj pierwszą liczbę: ");
    int a = scanner.nextInt();
    System.out.println("Podaj drugą liczbę:");
    int b = scanner.nextInt();
    System.out.println();
    System.out.println("Wynik dadawania to: " + (a +b ) );
    System.out.println("Wynik odejmowania to: " + (a - b) );
    System.out.println("Wynik mnożenia to: " + (a *b ) );
    System.out.println("Wynik dzielenia to: " + (a / b) );
    }
    }

  • @dawidtrela7150
    @dawidtrela7150 11 дней назад

    import java.util.Scanner;
    public class Main {
    public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    System.out.println("Program podaje wyniki podstawowych działań matematycznych dwóch");
    System.out.println("liczb całkowitych:");
    System.out.println();
    System.out.println("Podaj pierwszą liczbę:");
    int a = scanner.nextInt();
    System.out.println();
    System.out.println("Podaj drugą liczbę:");
    int b = scanner.nextInt();
    System.out.println();
    System.out.println("Suma: " + (a + b));
    System.out.println("Różnica " + (a - b));
    System.out.println("Iloczyn: " + (a * b));
    System.out.println("Iloraz: " + (a / b));

    }
    }