Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Java/Program-16/CSAOfCylinder.class
Binary file not shown.
14 changes: 14 additions & 0 deletions Java/Program-16/CSAOfCylinder.java
Original file line number Diff line number Diff line change
@@ -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");
}
}
3 changes: 3 additions & 0 deletions Java/Program-16/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Program 16

Program to find CSA of Cylinder
17 changes: 17 additions & 0 deletions Java/Program-17/ReverseString.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
3 changes: 3 additions & 0 deletions Java/Program-17/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Program 17

Program to reverse a given string
18 changes: 18 additions & 0 deletions Java/Program-18/ElectricityBill.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
3 changes: 3 additions & 0 deletions Java/Program-18/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Program-18

Program to calculate electricity bill
17 changes: 17 additions & 0 deletions Java/Program-19/Discount.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
3 changes: 3 additions & 0 deletions Java/Program-19/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Program 19

Program to calculate discount
15 changes: 15 additions & 0 deletions Java/Program-20/BattingAverage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.dsa;

import java.util.Scanner;

public class BattingAverage {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
System.out.println("Enter the number of runs scored by the batter");
int runs=input.nextInt();
System.out.println("Enter the number of times the batter got out ");
int out= input.nextInt();
int batting_avg=runs/out;
System.out.println("The batting average of the batter is "+batting_avg);
}
}
3 changes: 3 additions & 0 deletions Java/Program-20/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Program 20

Program to calculate batting average