Advertisement
Ligh7_of_H3av3n

06.Gold Mine

Oct 21st, 2023
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.00 KB | None | 0 0
  1. package SamiqtIzpit2;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class GoldMine {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.  
  10.         int location = Integer.parseInt(scanner.nextLine());
  11.         for (int i = 0; i < location; i++) {
  12.             double avrExtraction = Double.parseDouble(scanner.nextLine());
  13.             int days = Integer.parseInt(scanner.nextLine());
  14.             double sumExtraction = 0.0;
  15.             for (int j = 0; j < days; j++) {
  16.                 double extraction = Double.parseDouble(scanner.nextLine());
  17.                 sumExtraction += extraction;
  18.             }
  19.             double average = sumExtraction /days;
  20.             double neededGold = avrExtraction - average;
  21.             if(average >= avrExtraction) {
  22.                 System.out.printf("Good job! Average gold per day: %.2f.\n",average);
  23.             }else {
  24.                 System.out.printf("You need %.2f gold.\n", neededGold);
  25.             }
  26.         }
  27.     }
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement