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);
- double weight1 = 0;
- double weight2 = 0;
- double weight3 = 0;
- double total = 0;
- double average = 0;
- int n = Integer.parseInt(scanner.nextLine());
- for (int i = 0; i <n ; i++) {
- int weight = Integer.parseInt(scanner.nextLine());
- if (weight<=3){
- weight1 += weight;
- } else if ((4<=weight) && (weight<=11)){
- weight2 += weight;
- } else if (weight>=12){
- weight3 += weight;
- } total = weight1 + weight2 + weight3;
- average = ((weight1*200) + (weight2*175) + (weight3*120))/total;
- }
- System.out.printf("%.2f%n", average);
- System.out.printf("%.2f%%%n", (weight1/total)*100);
- System.out.printf("%.2f%%%n", (weight2/total)*100);
- System.out.printf("%.2f%%%n", (weight3/total)*100);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement