diff --git a/Java/Program-16/CSAOfCylinder.class b/Java/Program-16/CSAOfCylinder.class new file mode 100644 index 00000000..faaea7ba Binary files /dev/null and b/Java/Program-16/CSAOfCylinder.class differ diff --git a/Java/Program-16/CSAOfCylinder.java b/Java/Program-16/CSAOfCylinder.java new file mode 100644 index 00000000..3c2d563c --- /dev/null +++ b/Java/Program-16/CSAOfCylinder.java @@ -0,0 +1,14 @@ +package com.dsa; + +import java.util.Scanner; + +public class CSAOfCylinder { + public static void main(String[] args) { + Scanner input=new Scanner(System.in); + System.out.println("Enter radius and height of cylinder"); + float radius=input.nextFloat(); + float height=input.nextFloat(); + float CSA=2*3.14f*radius*height; + System.out.println("Curved surface area of cylinder is "+CSA+" square units"); + } +} \ No newline at end of file diff --git a/Java/Program-16/README.md b/Java/Program-16/README.md new file mode 100644 index 00000000..42d29ac9 --- /dev/null +++ b/Java/Program-16/README.md @@ -0,0 +1,3 @@ +Program 16 + +Program to find CSA of Cylinder \ No newline at end of file diff --git a/Java/Program-17/ReverseString.java b/Java/Program-17/ReverseString.java new file mode 100644 index 00000000..a9cabfbe --- /dev/null +++ b/Java/Program-17/ReverseString.java @@ -0,0 +1,17 @@ +package com.dsa; + +import java.util.Scanner; + +public class ReverseString { + public static void main(String[] args) { + Scanner input=new Scanner(System.in); + String reversed_string=""; + System.out.println("Enter the string"); + String string= input.next(); + for(int i=string.length()-1;i>=0;i--){ + reversed_string = reversed_string + string.charAt(i); + } + System.out.println("The original string is "+string); + System.out.println("The reversed string is "+reversed_string); + } +} \ No newline at end of file diff --git a/Java/Program-17/readme.md b/Java/Program-17/readme.md new file mode 100644 index 00000000..fa231970 --- /dev/null +++ b/Java/Program-17/readme.md @@ -0,0 +1,3 @@ +Program 17 + +Program to reverse a given string diff --git a/Java/Program-18/ElectricityBill.java b/Java/Program-18/ElectricityBill.java new file mode 100644 index 00000000..64823e3f --- /dev/null +++ b/Java/Program-18/ElectricityBill.java @@ -0,0 +1,18 @@ +//A consumer consumes n watts per hour daily for one month. +// Calculate the total energy bill of that consumer if per-unit rate is 7? +// ( In $, £, €, INR, DHR, Riyal etc.) [Take 1 month = 30 Days]. +package com.dsa; + +import java.util.Scanner; + +public class ElectricityBill { + public static void main(String[] args) { + Scanner input=new Scanner(System.in); + System.out.println("Enter the watts consumed per hour"); + int watts=input.nextInt(); + int electricity=watts*24*30;//Total watts of electricity consumed in 30 days + int cost=(electricity/1000)*7;//We divide by 1000 to convert watts to kilo-watts + //One unit=One kilo-watt and One unit costs 7 + System.out.println("The electricity bill is "+cost); + } +} diff --git a/Java/Program-18/readme.md b/Java/Program-18/readme.md new file mode 100644 index 00000000..250559c3 --- /dev/null +++ b/Java/Program-18/readme.md @@ -0,0 +1,3 @@ +Program-18 + +Program to calculate electricity bill \ No newline at end of file diff --git a/Java/Program-19/Discount.java b/Java/Program-19/Discount.java new file mode 100644 index 00000000..a8683a8b --- /dev/null +++ b/Java/Program-19/Discount.java @@ -0,0 +1,17 @@ +package com.dsa; + +import java.util.Scanner; + +public class Discount { + public static void main(String[] args) { + Scanner input=new Scanner(System.in); + System.out.println("Enter the original price of product"); + int original_price=input.nextInt(); + System.out.println("Enter the discount percentage"); + float discount=input.nextInt(); + float discount_price=original_price*(discount/100); + float final_price=original_price-discount_price; + System.out.println("The discount price is: "+discount_price); + System.out.println("The final price after discount is: "+final_price); + } +} diff --git a/Java/Program-19/readme.md b/Java/Program-19/readme.md new file mode 100644 index 00000000..a6d73f91 --- /dev/null +++ b/Java/Program-19/readme.md @@ -0,0 +1,3 @@ +Program 19 + +Program to calculate discount \ No newline at end of file