Skip to content

Commit 37a68be

Browse files
Chapter 8 Practice Set Solutions
1 parent 94bdfad commit 37a68be

File tree

4 files changed

+71
-0
lines changed

4 files changed

+71
-0
lines changed

39.Chapter_8_Practice_Set/Ch8_PS.pdf

595 KB
Binary file not shown.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
class Employee {
2+
int salary;
3+
String name;
4+
5+
public int getSalary() {
6+
return salary;
7+
}
8+
9+
public String getName() {
10+
return name;
11+
}
12+
13+
public void setName(String n) {
14+
name = n;
15+
}
16+
}
17+
18+
public class cwh_39_ps_pr_01 {
19+
public static void main(String args[]) {
20+
Employee kishan = new Employee();
21+
kishan.setName("Let's Code Together");
22+
kishan.salary = 50000;
23+
24+
//kishan.name = "Kishan";
25+
26+
System.out.println(kishan.getSalary());
27+
System.out.println(kishan.getName());
28+
}
29+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class Cellphone {
2+
public void ring() {
3+
System.out.println("ringing...");
4+
}
5+
6+
public void vibrate() {
7+
System.out.println("vibrating...");
8+
}
9+
10+
public void call() {
11+
System.out.println("calling your friend...");
12+
}
13+
}
14+
15+
public class cwh_39_ps_pr_02 {
16+
public static void main(String args[]) {
17+
Cellphone apple = new Cellphone();
18+
apple.ring();
19+
apple.vibrate();
20+
apple.call();
21+
}
22+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class Circle {
2+
double radius;
3+
4+
public double perimeter() {
5+
return (2 * radius * Math.PI);
6+
}
7+
8+
public double area() {
9+
return (Math.PI * radius * radius);
10+
}
11+
}
12+
13+
public class cwh_39_ps_pr_06 {
14+
public static void main(String args[]) {
15+
Circle cir = new Circle();
16+
cir.radius = 5.5;
17+
System.out.println(cir.perimeter());
18+
System.out.println(cir.area());
19+
}
20+
}

0 commit comments

Comments
 (0)