Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int numOfDays = sc.nextInt();
- double leftfoodkg = sc.nextDouble();
- double fooddogperdaykg = sc.nextDouble();
- double foodcatperdaykg = sc.nextDouble();
- double foodturtleperdaygrams = sc.nextDouble();
- double dog = numOfDays*fooddogperdaykg;
- double cat = numOfDays*foodcatperdaykg;
- double turtle = numOfDays*(foodturtleperdaygrams/1000);
- double total = dog+cat+turtle;
- if(total<=leftfoodkg) {
- leftfoodkg -= total;
- System.out.printf("%.0f kilos of food left.", Math.floor(leftfoodkg));
- }
- else if(total>leftfoodkg)
- {
- total-=leftfoodkg;
- System.out.printf("%.0f more kilos of food are needed.",Math.ceil(total));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement