Advertisement
skipter

Logistics - Java Basics

Apr 29th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.27 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class FOX {
  4.     public static void main(String[] args) {
  5.         Scanner input = new Scanner(System.in);
  6.         int tovarCounter = Integer.parseInt(input.nextLine());
  7.  
  8.         double microbus = 0; // 200lv ton
  9.         double truck = 0;   // 175lv ton
  10.         double train = 0;   // 120lv ton
  11.  
  12.         for (int i = 0; i < tovarCounter; i++) {
  13.             int currentHeight = Integer.parseInt(input.nextLine());
  14.             if (currentHeight <= 3 & currentHeight >= 1) {
  15.                 microbus += currentHeight;
  16.             } else if (currentHeight >= 4 & currentHeight <= 11) {
  17.                 truck += currentHeight;
  18.             } else if (currentHeight >= 12) {
  19.                 train += currentHeight;
  20.             }
  21.         }
  22.         double totalHeight = microbus + truck + train;
  23.         double microbusTax = microbus * 200;
  24.         double truckTax = truck * 175;
  25.         double trainTax = train * 120;
  26.         double sredenTonaj = (trainTax + truckTax + microbusTax) /  totalHeight;
  27.         System.out.printf("%.2f%n", sredenTonaj);
  28.         System.out.printf("%.2f%%%n",microbus/totalHeight*100);
  29.         System.out.printf("%.2f%%%n",truck/totalHeight*100);
  30.         System.out.printf("%.2f%%%n",train/totalHeight*100);
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement