Skip to content

Instantly share code, notes, and snippets.

@Peters8090
Last active October 5, 2019 15:06
Show Gist options
  • Save Peters8090/461c67752427f483b8cfd833bb1c184d to your computer and use it in GitHub Desktop.
Save Peters8090/461c67752427f483b8cfd833bb1c184d to your computer and use it in GitHub Desktop.
[Computer programming homework] Java introduction: Write a program that simulates calculator operations. Create variables number1 and number 2. Create variables summing [dodawanie], subtraction [odejmowanie] etc. Assign the results of specific mathematical operations to variables summing [dodawanie], subtraction [odejmowanie], etc.
package programowanie_komputerowe;
public class SimpleCalculator {
//liczby na ktorych beda wykonywane dzialania
static double liczba1 = Math.random();
static double liczba2 = Math.random();
//wyniki dzialan na liczbach 1 i 2
static double dodawanie = liczba1 + liczba2;
static double odejmowanie = liczba1 - liczba2;
static double mnozenie = liczba1 * liczba2;
static double dzielenie = liczba1 / liczba2;
public static void main(String[] args) {
//prezentacja wynikow
System.out.println(
"liczba1: " + liczba1
+ "\nliczba2: " + liczba2
+ "\ndodawanie: " + dodawanie
+ "\nodejmowanie: " + odejmowanie
+ "\nmnozenie: " + mnozenie
+ "\ndzielenie: " + dzielenie
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment