Advertisement
Ronka

Untitled

Jan 17th, 2017
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class num {
  4. public static void main(String[] args) {
  5. Scanner console = new Scanner(System.in);
  6. int V = Integer.parseInt(console.nextLine());
  7. int P1 = Integer.parseInt(console.nextLine());
  8. int P2 = Integer.parseInt(console.nextLine());
  9. double h = Double.parseDouble(console.nextLine());
  10.  
  11. if (V >= 1 && V <= 10000) {
  12. if (P1 > 0 && P1 <= 5000) {
  13. if (P2 > 0 && P2 <= 5000) {
  14. if (h > 0 && h < 25) {
  15. int sum = (int) ((P1 + P2) * h);
  16. int percentv = (int) (100 * sum / V); // х% от общото количество
  17. int percentp1 = (int) (P1 * h * 100 / sum); // %р1 общото количество = количеството на р1 за h часа
  18. int percentp2 = (int) (P2 * h * 100 / sum);
  19.  
  20. if (sum > V) {
  21. int overflow = (int) (sum - V);
  22. System.out.print("For " + h + " hours the pool overflows with " + overflow + " liters.");
  23. } else {
  24. //System.out.printf("The pool is %d% full. Pipe 1: %s%. Pipe 2: %m%" + percentv + percentp1 + percentp2); // ?
  25. System.out.println("The pool is " + percentv + "% full. Pipe 1: " + percentp1 + "%. Pipe 2: " + percentp2 + "%.");
  26. }
  27. }
  28. }
  29. }
  30. }
  31.  
  32.  
  33.  
  34.  
  35. }
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement