-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalculator.java
More file actions
40 lines (27 loc) · 920 Bytes
/
Copy pathcalculator.java
File metadata and controls
40 lines (27 loc) · 920 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//CalculatorFunctions
//Maryam Habibollahi
import java.util.Scanner; // program uses Scanner
public class Calculator {
//global variables:
public int x;
public int y;
Scanner scanIn = new Scanner(System.in); //creating a scanner
public int setFirst() { //ask for first number
System.out.println("Enter the first number:");
x = scanIn.nextInt();
return x; //save number in the app
}
public int setSecond() { //ask for second number
System.out.println("Enter the second number:");
y = scanIn.nextInt();
return y; //save number in the app
}
public int addNumbers(int a, int b) { //take numbers in app
int add = a+b;
return add;
}
public int multiplyNumbers(int a, int b) { //take numbers in app
int multp = a*b;
return multp;
}
}