Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyClass {
- public static void main(String args[]) {
- double food = 0.0;
- double hay = 0.0;
- double cover = 0.0;
- double weight = 0.0;
- java.util.Scanner scanner = new java.util.Scanner(System.in);
- food = scanner.nextDouble() * 1000;
- hay = scanner.nextDouble() * 1000;
- cover = scanner.nextDouble() * 1000;
- weight = scanner.nextDouble() * 1000;
- int days = 30;
- for (int day = 1; day <= 30; day++) {
- food -= 300;
- if (day % 2 == 0) {
- hay -= (0.05 * food);
- }
- if (day % 3 == 0) {
- cover -= (weight * 0.3333333333333333333);
- }
- if (food <= 0 || hay <= 0 || cover <= 0) {
- System.out.println("Merry must go to the store!");
- break;
- }
- }
- if (food > 0 && hay > 0 && cover > 0) {
- System.out.printf("Everything is fine! Puppy is happy! Food: %.2f, Hay: %.2f, Cover: %.2f.",food * 0.001,hay * 0.001,cover*0.001);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement