Skip to content

Commit 4e6466d

Browse files
committed
new
1 parent 6be86b2 commit 4e6466d

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed
-2.08 KB
Binary file not shown.
-2.38 KB
Binary file not shown.

src/com/sbiswas001/twelveproject/Rectangle.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ private void input() {
4848
2. Area of rectangle
4949
3. Length of Diagonal""");
5050
ch = Integer.parseInt(sc.next());
51+
if(ch > 3 || ch < 1) {
52+
System.out.println("Wrong input! Try again.");
53+
input();
54+
}
5155
}
5256

5357
/**
@@ -56,13 +60,14 @@ private void input() {
5660
private void menu() {
5761
switch (ch) {
5862
case 1:
59-
System.out.println("Perimeter of rectangle is " + (2*(length + breadth)));
63+
System.out.println("Perimeter of rectangle is " + (2*(length + breadth)) + " units");
6064
break;
6165
case 2:
62-
System.out.println("Area of rectangle is " + (length * breadth));
66+
System.out.println("Area of rectangle is " + (length * breadth) + " square units");
6367
break;
6468
case 3:
65-
System.out.println("Length of Diagonal is " + Math.sqrt(length * breadth));
69+
double d = Math.sqrt(Math.pow(length, 2) + Math.pow(breadth, 2));
70+
System.out.println("Length of Diagonal is " + d + " units");
6671
break;
6772
}
6873
}

0 commit comments

Comments
 (0)