Advertisement
Flaron

Udemy_28. PaintJob

Sep 14th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. package lista.Alapok;
  2.  
  3. public class Main {
  4.  
  5. public static int getBucketCount(double width, double height, double areaPerBucket, int extraBuckets) {
  6. if(width<=0.0 || height<=0.0 || areaPerBucket<=0.0 || extraBuckets<0) return -1;
  7.  
  8. double area=width*height;
  9. int bucketCount=(int)Math.ceil(area/areaPerBucket);
  10. return bucketCount-extraBuckets;
  11.  
  12. }
  13.  
  14. public static int getBucketCount(double width, double height, double areaPerBucket) {
  15. if (width <= 0.0 || height <= 0.0 || areaPerBucket <= 0.0) return -1;
  16. double area = width * height;
  17. return (int) Math.ceil(area / areaPerBucket);
  18. }
  19.  
  20. public static int getBucketCount(double area, double areaPerBucket) {
  21. if(area<=0.0 || areaPerBucket<=0.0) return -1;
  22. return (int)Math.ceil(area/areaPerBucket);
  23.  
  24. }
  25.  
  26. public static void main(String[] args) {
  27. System.out.println(getBucketCount(2.5,2.5,1.5,2));
  28. System.out.println(getBucketCount(2.5,2.5,1.5));
  29. System.out.println(getBucketCount(2.5,1.5));
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement