Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Fundamentals.Exams;
- import java.util.Scanner;
- public class GuineaPig {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double foodQuantity = Double.parseDouble(scanner.nextLine()) * 1000;
- double hayQuantity = Double.parseDouble(scanner.nextLine()) * 1000;
- double coverQuantity = Double.parseDouble(scanner.nextLine()) * 100;
- double guineaWeight = Double.parseDouble(scanner.nextLine()) * 100;
- int days = 1;
- while (days <= 30) {
- foodQuantity -= 300;
- if (days % 2 == 0) {
- hayQuantity -= foodQuantity * 0.05;
- }
- if (days % 3 == 0) {
- coverQuantity -= guineaWeight / 3;
- }
- days++;
- }
- foodQuantity /= 1000;
- hayQuantity /= 1000;
- coverQuantity /= 1000;
- boolean checker = foodQuantity >0 && hayQuantity > 0 && coverQuantity > 0;
- if (checker) {
- System.out.printf("Everything is fine! Puppy is happy! Food: %.2f, Hay: %.2f, Cover: %.2f.", foodQuantity, hayQuantity, coverQuantity);
- } else {
- System.out.println("Merry must go to the pet store!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment