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()) * 1000;
- double guineaWeight = Double.parseDouble(scanner.nextLine()) * 1000;
- int dayCount = 0;
- while (dayCount < 30 && foodQuantity >0 && hayQuantity > 0 && coverQuantity > 0) {
- dayCount++;
- foodQuantity -= 300;
- if (dayCount % 2 == 0) {
- hayQuantity = hayQuantity - (hayQuantity * 0.5);
- }
- if (dayCount % 3 == 0) {
- coverQuantity = coverQuantity - (guineaWeight * 1/3);
- }
- }
- foodQuantity = foodQuantity / 1000;
- hayQuantity = hayQuantity / 1000;
- coverQuantity = 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