forked from braughtg/github-issues-activity-f18
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Calculator.java
149 lines (136 loc) · 2.94 KB
/
Calculator.java
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/**
* Simple calculator class for Git/GitHub Activity.
*
* Note: This code contains lots of intentional mistakes. They all correspond to
* issues in the GitHub issue tracker and will be fixed as a part of the
* activity.
*
* @author braught
* @version 1.0
*/
public class Calculator {
/**
* Add two double values.
*
* @param x
* a double
* @param y
* a double
* @return x + y
*/
public double plus(double x, double y) {
return x + y;
}
/**
* Subtract two double values.
*
* @param x
* a double
* @param y
* a double
* @return x - y
*/
public double sub(double x, double y) {
return x-y ;
}
/**
* Multiply two double values.
*
* @param x
* a double
* @param y
* a double
* @return x * y
*/
public double mult(double x, double y) {
return x * y;
}
/**
* Divide two double values.
*
* @param x
* a double
* @param y
* a double
* @return x/y
*/
public double doDivision(double x, double y) {
return x/y;
}
/**
* The length of the hypotenuse of a right triangle with the given side lengths.
*
* @param x
* the length of one side.
* @param y
* the length of the other side.
* @return the length of the hypotenuse of a right triangle with sides x and y.
*/
public double hypotenuse(double x, double y) {
return Math.sqrt(Math.pow(x,2) + Math.pow(y, 2));
}
/**
* The length of a rectangle with the given side lengths.
*
* @param x
* the length of one side.
* @param y
* the length of the other side.
* @return the area of a rectangle with sides x and y.
*/
public double rectAr(double x, double y) {
return x*y;
}
/**
* The perimeter of a rectangle with the given side lengths.
*
* @param x
* the length of one side.
* @param y
* the length of the other side.
* @return the perimeter of a rectangle with sides x and y.
*/
public double rectPer(double x, double y) {
return 2 * x * y;
}
/**
* The area of a circle with given radius.
*
* @param r
* the radius
* @return the area of a circle with radius r.
*/
public double areaOfCircle(double r) {
return Math.PI * r * r;
}
/**
* The perimeter of a circle with given radius.
*
* @param r
* the radius
* @return the perimeter of a circle with radius r.
*/
public double cirPer(double r) {
return Math.PI * r * r;
}
/**
* The volume of a cube with the given side length.
*
* @param s
* the side length
* @return the volume of a cube with sides of length s.
*/
public double cubeVolume(double s) {
return 4 * s;
}
/**
* The volume of a sphere with the given radius.
*
* @param r
* the radius
* @return the volume of a sphere with radius r.
*/
public double sphVol(double r) {
return 4/3 * Math.PI * r * r * r;
}
}