Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Dictionary;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int days = Integer.parseInt(sc.nextLine());
- int ostavenaHrana = Integer.parseInt(sc.nextLine());
- double elen1 = Double.parseDouble(sc.nextLine());
- double elen2 = Double.parseDouble(sc.nextLine());
- double elen3 = Double.parseDouble(sc.nextLine());
- double nujnaHrana = days*(elen1+elen2+elen3);
- if (ostavenaHrana >= nujnaHrana){
- double res = Math.floor(ostavenaHrana-nujnaHrana);
- System.out.printf("%.0f kilos of food left.",res);
- } else {
- double res = Math.ceil(nujnaHrana-ostavenaHrana);
- System.out.printf("%.0f more kilos of food are needed.",res);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment