From c5e31154a4349329720ee14fabebf2a9ac3483bd Mon Sep 17 00:00:00 2001 From: Naman Date: Fri, 29 Apr 2022 16:58:53 +0530 Subject: [PATCH 1/2] Assignment_2 Added --- Assignment_2.java | 85 +++++++++++++++++++++++++++++++++++++++++++++++ README.md | 1 - 2 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 Assignment_2.java delete mode 100644 README.md diff --git a/Assignment_2.java b/Assignment_2.java new file mode 100644 index 0000000..21dadf1 --- /dev/null +++ b/Assignment_2.java @@ -0,0 +1,85 @@ +package Core_Java_Assignments; + +import java.util.Scanner; + +public class Assignment_2 { + + public static void main(String[] args) { + + System.out.println("Welcome to Shape Calculator..."); + System.out.println("Please Enter Shape name..!"); + Scanner sc = new Scanner(System.in); + String shape = sc.next(); + + switch (shape) { + case "circle": + System.out.println("Please Enter Radious"); + int r = sc.nextInt(); + + System.out.println("Area Of circle is :" + 3.14 * (r * r)); + System.out.println("Perimeter Of Ciecle is :" + 2 * 3.14 * r); + break; + + case "tringle": + System.out.println("Please Enter Hight"); + int th = sc.nextInt(); + System.out.println("Please Enter Base"); + int tb = sc.nextInt(); + System.out.println("Area Of Tringle is :" + 12 * tb * th); + System.out.println("Perimeter Of Tringle is :" + 12 * tb * th); + break; + + case "square": + System.out.println("Please Enter Length"); + int a = sc.nextInt(); + System.out.println("Area Of Square is :" + a * a); + System.out.println("Perimeter Of Square is :" + 4 * a); + break; + case "cylinder": + System.out.println("Please Enter Radious"); + int cr = sc.nextInt(); + System.out.println("Please Enter Hight"); + int ch = sc.nextInt(); + + System.out.println("Volume Of cylinder is :" + 3.14 * (cr * cr) * ch); + System.out.println("Susface Area Of cylinder is :" + 2 * 3.14 * cr * ch); + System.out.println("Area Of cylinder is :" + 2 * 3.14 * cr * (ch + cr)); + + break; + case "rectangle": + System.out.println("Please Enter Length"); + int rec = sc.nextInt(); + System.out.println("Please Enter Breadth"); + int recb = sc.nextInt(); + System.out.println("Area Of rectangle is :" + rec * recb); + System.out.println("Perimeter Of rectangle is :" + 2 * (rec + recb)); + break; + + case "cube": + System.out.println("Please Enter Side"); + int cube_l = sc.nextInt(); + System.out.println("Volume Of cube is :" + (cube_l * cube_l * cube_l)); + System.out.println("Susface Area Of cube is :" + 6 * (cube_l * cube_l)); + System.out.println("Perimeter Of cube is :" + 12 * (cube_l)); + + break; + case "cuboid": + System.out.println("Please Enter Length"); + int cuboid_l = sc.nextInt(); + System.out.println("Please Enter Breadth"); + int cuboid_b = sc.nextInt(); + System.out.println("Please Enter Hight"); + int cuboid_h = sc.nextInt(); + System.out.println("Volume Of cuboid is :" + (cuboid_l * cuboid_b * cuboid_h)); + System.out.println("Susface Area Of cuboid is :" + 2 * ((cuboid_l * cuboid_b) + (cuboid_b * cuboid_h) + (cuboid_l * cuboid_h))); + System.out.println("Perimeter Of cuboid is :" + 4 * (cuboid_l + cuboid_b + cuboid_h)); + + break; + + default: + System.out.println("You Entered Figure is Not Valid"); + } + + } + +} diff --git a/README.md b/README.md deleted file mode 100644 index e5d4536..0000000 --- a/README.md +++ /dev/null @@ -1 +0,0 @@ -# core_Java_Assingment- \ No newline at end of file From b82bc1e99d7614cc5c19ef2e6f328eafd89cc36d Mon Sep 17 00:00:00 2001 From: Naman Date: Sun, 1 May 2022 11:11:10 +0530 Subject: [PATCH 2/2] Assignment_2 Added --- Assignment_2.java | 85 --------------------------- Assignment_2.md | 145 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 145 insertions(+), 85 deletions(-) delete mode 100644 Assignment_2.java create mode 100644 Assignment_2.md diff --git a/Assignment_2.java b/Assignment_2.java deleted file mode 100644 index 21dadf1..0000000 --- a/Assignment_2.java +++ /dev/null @@ -1,85 +0,0 @@ -package Core_Java_Assignments; - -import java.util.Scanner; - -public class Assignment_2 { - - public static void main(String[] args) { - - System.out.println("Welcome to Shape Calculator..."); - System.out.println("Please Enter Shape name..!"); - Scanner sc = new Scanner(System.in); - String shape = sc.next(); - - switch (shape) { - case "circle": - System.out.println("Please Enter Radious"); - int r = sc.nextInt(); - - System.out.println("Area Of circle is :" + 3.14 * (r * r)); - System.out.println("Perimeter Of Ciecle is :" + 2 * 3.14 * r); - break; - - case "tringle": - System.out.println("Please Enter Hight"); - int th = sc.nextInt(); - System.out.println("Please Enter Base"); - int tb = sc.nextInt(); - System.out.println("Area Of Tringle is :" + 12 * tb * th); - System.out.println("Perimeter Of Tringle is :" + 12 * tb * th); - break; - - case "square": - System.out.println("Please Enter Length"); - int a = sc.nextInt(); - System.out.println("Area Of Square is :" + a * a); - System.out.println("Perimeter Of Square is :" + 4 * a); - break; - case "cylinder": - System.out.println("Please Enter Radious"); - int cr = sc.nextInt(); - System.out.println("Please Enter Hight"); - int ch = sc.nextInt(); - - System.out.println("Volume Of cylinder is :" + 3.14 * (cr * cr) * ch); - System.out.println("Susface Area Of cylinder is :" + 2 * 3.14 * cr * ch); - System.out.println("Area Of cylinder is :" + 2 * 3.14 * cr * (ch + cr)); - - break; - case "rectangle": - System.out.println("Please Enter Length"); - int rec = sc.nextInt(); - System.out.println("Please Enter Breadth"); - int recb = sc.nextInt(); - System.out.println("Area Of rectangle is :" + rec * recb); - System.out.println("Perimeter Of rectangle is :" + 2 * (rec + recb)); - break; - - case "cube": - System.out.println("Please Enter Side"); - int cube_l = sc.nextInt(); - System.out.println("Volume Of cube is :" + (cube_l * cube_l * cube_l)); - System.out.println("Susface Area Of cube is :" + 6 * (cube_l * cube_l)); - System.out.println("Perimeter Of cube is :" + 12 * (cube_l)); - - break; - case "cuboid": - System.out.println("Please Enter Length"); - int cuboid_l = sc.nextInt(); - System.out.println("Please Enter Breadth"); - int cuboid_b = sc.nextInt(); - System.out.println("Please Enter Hight"); - int cuboid_h = sc.nextInt(); - System.out.println("Volume Of cuboid is :" + (cuboid_l * cuboid_b * cuboid_h)); - System.out.println("Susface Area Of cuboid is :" + 2 * ((cuboid_l * cuboid_b) + (cuboid_b * cuboid_h) + (cuboid_l * cuboid_h))); - System.out.println("Perimeter Of cuboid is :" + 4 * (cuboid_l + cuboid_b + cuboid_h)); - - break; - - default: - System.out.println("You Entered Figure is Not Valid"); - } - - } - -} diff --git a/Assignment_2.md b/Assignment_2.md new file mode 100644 index 0000000..b44c1d7 --- /dev/null +++ b/Assignment_2.md @@ -0,0 +1,145 @@ +package Core_Java_Assignments; + +import java.util.Scanner; + +class calculator { + + void circle() { + System.out.println("Please Enter Radious"); + Scanner sc = new Scanner(System.in); + int r = sc.nextInt(); + + System.out.println("Area Of circle is :" + 3.14 * (r * r)); + System.out.println("Perimeter Of Ciecle is :" + 2 * 3.14 * r); + + } + + void square() { + + System.out.println("Please Enter Length"); + Scanner sc = new Scanner(System.in); + int a = sc.nextInt(); + System.out.println("Area Of Square is :" + a * a); + System.out.println("Perimeter Of Square is :" + 4 * a); + } + + void traingle() { + + System.out.println("Please Enter Hight"); + Scanner sc = new Scanner(System.in); + int th = sc.nextInt(); + System.out.println("Please Enter Base"); + int tb = sc.nextInt(); + System.out.println("Area Of Tringle is :" + 12 * tb * th); + System.out.println("Perimeter Of Tringle is :" + 12 * tb * th); + } + + void cylinder() { + System.out.println("Please Enter Radious"); + Scanner sc = new Scanner(System.in); + + int cr = sc.nextInt(); + System.out.println("Please Enter Hight"); + int ch = sc.nextInt(); + + System.out.println("Volume Of cylinder is :" + 3.14 * (cr * cr) * ch); + System.out.println("Susface Area Of cylinder is :" + 2 * 3.14 * cr * ch); + System.out.println("Area Of cylinder is :" + 2 * 3.14 * cr * (ch + cr)); + + } + + void rectangle() { + System.out.println("Please Enter Length"); + Scanner sc = new Scanner(System.in); + + int rec = sc.nextInt(); + System.out.println("Please Enter Breadth"); + int recb = sc.nextInt(); + System.out.println("Area Of rectangle is :" + rec * recb); + System.out.println("Perimeter Of rectangle is :" + 2 * (rec + recb)); + } + + void cube() { + System.out.println("Please Enter Side"); + Scanner sc = new Scanner(System.in); + + int cube_l = sc.nextInt(); + System.out.println("Volume Of cube is :" + (cube_l * cube_l * cube_l)); + System.out.println("Susface Area Of cube is :" + 6 * (cube_l * cube_l)); + System.out.println("Perimeter Of cube is :" + 12 * (cube_l)); + } + + void cuboid() { + System.out.println("Please Enter Length"); + Scanner sc = new Scanner(System.in); + + int cuboid_l = sc.nextInt(); + System.out.println("Please Enter Breadth"); + int cuboid_b = sc.nextInt(); + System.out.println("Please Enter Hight"); + int cuboid_h = sc.nextInt(); + System.out.println("Volume Of cuboid is :" + (cuboid_l * cuboid_b * cuboid_h)); + System.out.println("Susface Area Of cuboid is :" + 2 * ((cuboid_l * cuboid_b) + (cuboid_b * cuboid_h) + (cuboid_l * cuboid_h))); + System.out.println("Perimeter Of cuboid is :" + 4 * (cuboid_l + cuboid_b + cuboid_h)); + + } + + void tringle() { + System.out.println("Please Enter Hight"); + Scanner sc = new Scanner(System.in); + + int th = sc.nextInt(); + System.out.println("Please Enter Base"); + int tb = sc.nextInt(); + System.out.println("Area Of Tringle is :" + 12 * tb * th); + System.out.println("Perimeter Of Tringle is :" + 12 * tb * th); + } + +} + +public class Demo { + + public static void main(String[] args) { + System.out.println("Dimension Calculator.."); + System.out.println("Menue..!"); + System.out.println("1. Circle"); + System.out.println("2. squre"); + System.out.println("3. cube"); + System.out.println("4. cuboid"); + System.out.println("5. Rectangle"); + System.out.println("6. tringle"); + + System.out.println("Please Enter Choice...!"); + Scanner sc = new Scanner(System.in); + int i = sc.nextInt(); + calculator cal = new calculator(); + + switch (i) { + case 1: + cal.circle(); + break; + + case 2: + cal.square(); + break; + + case 3: + cal.cube(); + break; + case 4: + cal.cuboid(); + break; + case 5: + cal.rectangle(); + break; + case 6: + cal.tringle(); + break; + default: + System.out.println("Invalid Option..!"); + + } + + } + +}