Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- public class Calculator {
- private int a;
- private int b;
- private int result;
- private String type;
- private String sentence;
- private boolean is = true;
- public void setA(int a) {
- this.a = a;
- }
- public void setB(int b) {
- this.b = b;
- }
- public void add() {
- result = a + b;
- ResultManager add = new ResultManager(this.result);
- }
- public void exponentiation() {
- type = "potegowania";
- result = (int) Math.pow(a, b);
- ResultManager power = new ResultManager(this.result, type);
- }
- private boolean ifFirst(int x) {
- boolean is = true;
- for (int i = 2; i < x; i++) {
- if (x % i == 0) {
- is = false;
- return is;
- }
- }
- return is;
- }
- public void getFirstNumbers() {
- boolean c;
- int j = 0;
- for (int i = a; i <= b; i++) {
- c = ifFirst(i);
- if (c == true) {
- j++;
- } else
- continue;
- }
- String sentence = "Pomiedzy " + a + " i " + b + " jest " + j + " liczb pierwszych";
- new ResultManager(sentence);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement