java_code

Created Diff never expires
28 removals
Lines
Total
Removed
Words
Total
Removed
To continue using this feature, upgrade to
Diffchecker logo
Diffchecker Pro
22 lines
28 additions
Lines
Total
Added
Words
Total
Added
To continue using this feature, upgrade to
Diffchecker logo
Diffchecker Pro
23 lines
import java.util.*;
import java.util.*;
public class Main {
public class Main
public static void main(String[] args) {
{
Scanner sc = new Scanner(System.in);
public static void main(String[] args)
System.out.println("Input the radius of coin");
{
double rad = sc.nextDouble();
Scanner sc = new Scanner(System.in);
System.out.println("Input the thickness of coin");
System.out.println("Input the radius of coin");
double thick = sc.nextDouble();
double rad = sc.nextDouble();
System.out.println("Input the target distance of coin");
System.out.println("Input the target distance of coin");
double dist = sc.nextDouble();
double dist = sc.nextDouble();
double no_of_blocks = 0;
double length = 2 * rad;
double no_of_blocks=0.0;
double curr_length=0.0;
double length=2*rad;
double n=1;
double curr_length=0.0;
while(curr_length < dist) {
double n=1.0;
no_of_blocks+=1;
while(curr_length<dist){
curr_length = curr_length + (length*(1/(2*n)));
no_of_blocks++;
n+=1;
curr_length = curr_length + (length*(1/(2*n)));
}
n++;
System.out.println("Number of blocks required are: " + no_of_blocks);
}
}
System.out.printf("NO of blocks required are %d" , (int)no_of_blocks);
}
}
}