SHARE
TWEET

Untitled

a guest Nov 20th, 2019 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class DemoFororororLogistics {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int n = Integer.parseInt(scanner.nextLine());
  8.  
  9.         double priceBus = 200;
  10.         double priceTruck = 175;
  11.         double priceTrain = 120;
  12.  
  13.         double withBus = 0;
  14.         int countB = 0;
  15.         double withTruck = 0;
  16.         double countTck = 0;
  17.         double withTrain = 0;
  18.         double countTrain = 0;
  19.  
  20.         double cargoNumber = 0;
  21.  
  22.  
  23.         //  • До 3 тона – микробус (200 лева на тон)
  24. //•   От 4 до 11 тона – камион (175 лева на тон)
  25. //  12 и повече тона – влак (120 лева на тон)
  26.  
  27.  
  28.         for (int i = 0; i < n; i++) {
  29.  
  30.  
  31.             double cargo = Integer.parseInt(scanner.nextLine());
  32.             cargoNumber += cargo;
  33.  
  34.  
  35.             if (cargo <= 3) {
  36.                 withBus += priceBus * cargo;
  37.                 countB += cargo;
  38.  
  39.             } else if (cargo <= 11) {
  40.                 withTruck += priceTruck * cargo;
  41.                 countTck += cargo;
  42.             } else {
  43.                 withTrain += priceTrain * cargo;
  44.                 countTrain += cargo;
  45.             }
  46.  
  47.  
  48.         }
  49.         double cost = ((withBus + withTruck + withTrain) / cargoNumber);
  50.         double bus = (countB / cargoNumber) * 100;
  51.         double truck = (countTck / cargoNumber) * 100;
  52.         double train = (countTrain / cargoNumber) * 100;
  53.  
  54.  
  55.         System.out.printf("%.2f%n%.2f%%%n%.2f%%%n%.2f%%", cost, bus, truck, train);
  56.  
  57.  
  58.     }
  59. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top