Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int locations = Integer.parseInt(scanner.nextLine());
- for (int i = 0; i < locations; i++) {
- double averageGold = Double.parseDouble(scanner.nextLine()),
- gold, goldSum = 0;
- int dayDigging = Integer.parseInt(scanner.nextLine());
- for (int j = 0; j < dayDigging; j++) {
- gold = Double.parseDouble(scanner.nextLine());
- goldSum += gold;
- }
- if (goldSum / dayDigging >= averageGold) {
- System.out.printf("Good job! Average gold per day: %.2f.\n", goldSum / dayDigging);
- } else {
- System.out.printf("You need %.2f gold.\n", averageGold - (goldSum / dayDigging));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement