Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class GuineaPig {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double food = Double.parseDouble(scanner.nextLine());
- double hay = Double.parseDouble(scanner.nextLine());
- double cover = Double.parseDouble(scanner.nextLine());
- double weight = Double.parseDouble(scanner.nextLine());
- double foodGr = food * 1000;
- double hayGr = hay * 1000;
- double coverGr = cover * 1000;
- double weightGr = weight * 1000;
- int days = 1;
- while (days <= 30) {
- foodGr -= 300;
- if (days % 2 == 0) {
- hayGr -= (foodGr * 5) / 100;
- }
- if (days % 3 == 0) {
- coverGr -= weightGr * 0.3333;
- }
- days++;
- }
- double foodKg = foodGr / 1000;
- double hayKg = hayGr / 1000;
- double coverKg = coverGr / 1000;
- if (foodKg >= 0 && hayKg >= 0 && coverKg >= 0) {
- System.out.printf("Everything is fine! Puppy is happy! Food: %.2f, Hay: %.2f, Cover: %.2f.",
- foodKg, hayKg, coverKg);
- } else if (foodKg < 0 || hayKg < 0 || coverKg < 0) {
- System.out.println("Merry must go to the pet store!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment