From 793254391cc0a138c44f0f7a5b94217b4ee6e964 Mon Sep 17 00:00:00 2001 From: nopedawn Date: Sun, 9 Oct 2022 16:09:41 +0700 Subject: [PATCH 1/2] Create TwoDimensional.java --- .java/TwoDimensional.java | 63 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .java/TwoDimensional.java diff --git a/.java/TwoDimensional.java b/.java/TwoDimensional.java new file mode 100644 index 0000000..7eb6e6b --- /dev/null +++ b/.java/TwoDimensional.java @@ -0,0 +1,63 @@ +import java.util.Scanner; + +public class TwoDimensional { + static Scanner input = new Scanner(System.in); + public static void main(String args[]){ + String loop = "y"; + while(loop.equalsIgnoreCase("y")){ + System.out.println(""); + System.out.println("--TWO DIMENSIONAL SHAPE COUNTER--"); + System.out.println("---------------------------------"); + System.out.println("1. Rectangle Area"); + System.out.println("2. Circle Area"); + System.out.println("3. Triangle Area"); + System.out.println("4. Quit"); + System.out.println("---------------------------------"); + System.out.print("Select Option [1-4] : "); + + int choose = input.nextInt(); + System.out.println(""); + + switch(choose){ + case 1: + int l, w, rectangle; + System.out.print("Enter Length (l)\n>> "); + l=input.nextInt(); + System.out.print("Enter Width (w)\n>> "); + w=input.nextInt(); + rectangle = l * w; + System.out.println("Area of Rectangle is : " + rectangle); + System.out.println(); + break; + case 2: + double pi, r, circle; + pi = 3.14; + System.out.print("Enter radius (r)\n>> "); + r = input.nextDouble(); + circle = pi * r * r; + System.out.println("Area of Circle is : " + circle); + System.out.println(); + break; + case 3: + double b, h, triangle; + System.out.print("Enter base (b)\n>> "); + b = input.nextDouble(); + System.out.print("Enter height (h)\n>> "); + h = input.nextDouble(); + triangle = (b * h) / 2; + System.out.println("Area of Triangle is : " + triangle); + System.out.println(); + break; + case 4: + System.exit(4); + break; + + default: + System.out.println("Enter only options [1-4]"); + } + System.out.print("Want to recalculate the area? [y/n] : "); + loop = input.next(); + } + } + +} From 344994eca5903c8d566dccb00dbfb2707c9b1bc1 Mon Sep 17 00:00:00 2001 From: nopedawn <62634724+nopedawn@users.noreply.github.com> Date: Sun, 9 Oct 2022 16:20:46 +0700 Subject: [PATCH 2/2] Update README.md --- .java/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.java/README.md b/.java/README.md index 7e6fe6d..562c361 100644 --- a/.java/README.md +++ b/.java/README.md @@ -7,9 +7,10 @@ * Insertion_Sort.java * NUMBER GUESSING GAME.java * QuickSort.java +* TwoDimensional.java * selectionSort.java * videodownloader.java ### Searching Algorithms * binarySearch.java -* linearSearch.java \ No newline at end of file +* linearSearch.java