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