Advertisement
Dilyana86

Untitled

Apr 13th, 2017
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. import java.text.DecimalFormat;
  2. import java.util.Scanner;
  3.  
  4. public class tiles240416 {
  5.  
  6. public static void main(String[] args) {
  7. Scanner input = new Scanner(System.in);
  8. int n = input.nextInt();
  9. double w = input.nextDouble();
  10. double l = input.nextDouble();
  11. int m = input.nextInt();
  12. int o = input.nextInt();
  13.  
  14. int area = (n * n) - (m * o);
  15. double tileArea = w * l;
  16. double tilesCount = (double) area / tileArea;
  17. double time = tilesCount * 0.2;
  18. double a1 = tilesCount * 10 % 10;
  19. int b1 = (int) a1;
  20. double a2 = a1 * 10 % 10;
  21. int b2 = (int) a2;
  22. double c1 = time * 10 % 10;
  23. int d1 = (int) c1;
  24. double c2 = c1 * 10 % 10;
  25. int d2 = (int) c2;
  26.  
  27. DecimalFormat df1 = new DecimalFormat("0.###########");
  28. DecimalFormat df2 = new DecimalFormat("0.############");
  29.  
  30. if (b1 == 9 && b2 == 9 && d1 == 9 && d2 == 9) {
  31. System.out.printf("%.0f\n%.0f", tilesCount, time);
  32. } else if (b1 == 9 && b2 == 9) {
  33. System.out.printf("%.0f\n%s", tilesCount, df2.format(time));
  34. } else if (d1 == 9 && d2 == 9) {
  35. System.out.printf("%s\n%.0f", df1.format(tilesCount), time);
  36. } else {
  37. System.out.printf("%s\n%s", df1.format(tilesCount), df2.format(time));
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement