Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class E02schoolTrip {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double days = Double.parseDouble(scanner.nextLine());
- double kg = Double.parseDouble(scanner.nextLine());
- double firstDogg = Double.parseDouble(scanner.nextLine());
- double secondDogg = Double.parseDouble(scanner.nextLine());
- double thirdDogg = Double.parseDouble(scanner.nextLine());
- double total = days * (firstDogg + secondDogg + thirdDogg);
- if (total > kg) {
- System.out.printf("%.0f more kilos of food are needed.", Math.ceil(total - kg));
- } else {
- System.out.printf("%.0f kilos of food left.", Math.floor(kg - total));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment