Advertisement
paykova

Logistics

Oct 13th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Logistics {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. double weight1 = 0;
  8. double weight2 = 0;
  9. double weight3 = 0;
  10. double total = 0;
  11. double average = 0;
  12.  
  13. int n = Integer.parseInt(scanner.nextLine());
  14. for (int i = 0; i <n ; i++) {
  15. int weight = Integer.parseInt(scanner.nextLine());
  16. if (weight<=3){
  17. weight1 += weight;
  18. } else if ((4<=weight) && (weight<=11)){
  19. weight2 += weight;
  20. } else if (weight>=12){
  21. weight3 += weight;
  22. } total = weight1 + weight2 + weight3;
  23. average = ((weight1*200) + (weight2*175) + (weight3*120))/total;
  24. }
  25. System.out.printf("%.2f%n", average);
  26. System.out.printf("%.2f%%%n", (weight1/total)*100);
  27. System.out.printf("%.2f%%%n", (weight2/total)*100);
  28. System.out.printf("%.2f%%%n", (weight3/total)*100);
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement