-
Notifications
You must be signed in to change notification settings - Fork 0
/
Assn5.java
67 lines (44 loc) · 1005 Bytes
/
Assn5.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
//Number 1
import java.util.Scanner;
class Num1 {
public static void main(String args[]) {
int times;
String phrase;
Scanner kb = new Scanner(System.in);
System.out.print("Int? ");
times = kb.nextInt();
System.out.print("Phrase? ");
kb.nextLine();
phrase = kb.nextLine();
for(int i = 0; i < times; i++) {
System.out.println(phrase);
}
}
}
class RightTriangle {
private double base, height;
public RightTriangle() {
base = 1;
height = 1;
}
public RightTriangle(double base, double height) {
this.base = base;
this.height = height;
}
public double getBase() {return base;}
public double getHeight() {return height;}
public void setBase(double in) {
if (in > 0)
base = in;
}
public void setHeight(double in) {
if (in > 0)
height = in;
}
public double getArea() {
return base*height/2;
}
public String toString() {
return "Right triangle with a base of " + base + " and a height of " + height+ ".";
}
}