-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSumIt.java
More file actions
38 lines (29 loc) · 812 Bytes
/
Copy pathSumIt.java
File metadata and controls
38 lines (29 loc) · 812 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
package com.example.sum;
public class SumIt {
// instance variables
private double one, two, sum;
// use the two parameters to set the values of your two instance variables
public void setNums(double num1, double num2) {
one = num1;
two = num2;
}
// sum the two numbers here
public void sum() {
sum = one + two;
}
// print the sum here
public void print() {
System.out.println(sum);
}
public static void main(String[] args) {
SumIt runner = new SumIt();
// should print out 12
runner.setNums(5, 7);
runner.sum();
runner.print();
// should print out 40
runner.setNums(13, 27);
runner.sum();
runner.print();
}
}