Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class P4 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- // Първоначално се чете един ред:
- // Брой дни – цяло число в диапазона [1…30]
- // Общо количество храна – реално число в диапазона [0.00…10000.00]
- // След това за всеки ден се чете:
- // o Количество изядена храна от кучето – цяло число в диапазона [10…500]
- // o Количество изядена храна от котката – цяло число в диапазона [10…500]
- int numDays = Integer.parseInt(scanner.nextLine());
- double totalFood = Double.parseDouble(scanner.nextLine());
- // int eatenFoodDog ;
- // int eatenFoodCat ;
- /* int startCount = Integer.parseInt(scanner.nextLine());
- int stops = Integer.parseInt(scanner.nextLine());
- for (int stop = 1; stop <= stops ; stop++) {
- int outCount = Integer.parseInt(scanner.nextLine());
- int inCount = Integer.parseInt(scanner.nextLine());
- startCount -= outCount;
- startCount += inCount; */
- int eatenFoodDog = 0;
- int eatenFoodCat = 0;
- for (int i = 1; i <= numDays; numDays++) {
- int eatenFoodDogDaily = Integer.parseInt(scanner.nextLine());
- int eatenFoodCatDaily = Integer.parseInt(scanner.nextLine());
- eatenFoodDog += eatenFoodDogDaily;
- eatenFoodCat += eatenFoodCatDaily;
- // if (numDays % 3 == 0) {
- // double Bonus = 0.10 * (eatenFoodDog + eatenFoodCat);
- // double Food = eatenFoodCat + eatenFoodDog + Bonus - Bonus;
- // 10% от 110 + 40 – 15гр.
- // Общо изядена храна: 600гр
- // }
- double TotalEatenFood = totalFood - (eatenFoodDog + eatenFoodCat);
- System.out.printf("Total eaten biscuits: %fgr.", TotalEatenFood);
- // Общо изядена храна: 600гр.
- // Изядена храна от кучето: 510гр, от котката: 90гр.
- double PercentageEatenFood = (TotalEatenFood) /1000 * totalFood;
- System.out.printf("%.2f of the food has been eaten.%n",PercentageEatenFood);
- double PercentageDog = eatenFoodDog * 100 * TotalEatenFood;
- System.out.printf("%.2f eaten from the dog.%n", PercentageDog);
- double PercentageCat = eatenFoodCat * 100 * TotalEatenFood;
- System.out.printf("%.2f eaten from the cat.%n", PercentageCat);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement