Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Logistics {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int cargoCount = Integer.parseInt(scanner.nextLine());
- double bus = 0, truck = 0, train = 0, totalCargo = 0;
- for (int i = 0; i < cargoCount; i++) {
- double cargo = Double.parseDouble(scanner.nextLine());
- if (cargo < 4) {
- bus += cargo;
- } else if (cargo < 12) {
- truck += cargo;
- } else {
- train += cargo;
- }
- totalCargo += cargo;
- }
- double average = (bus * 200 + truck * 175 + train * 120) / totalCargo;
- System.out.printf("%.2f\n", average);
- System.out.printf("%.2f%%\n", bus / totalCargo * 100);
- System.out.printf("%.2f%%\n", truck / totalCargo * 100);
- System.out.printf("%.2f%%\n", train / totalCargo * 100);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement