galinyotsev123

ProgBasicsExam1and2December2018-E02schoolTrip

Dec 29th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class E02schoolTrip {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. double days = Double.parseDouble(scanner.nextLine());
  8. double kg = Double.parseDouble(scanner.nextLine());
  9. double firstDogg = Double.parseDouble(scanner.nextLine());
  10. double secondDogg = Double.parseDouble(scanner.nextLine());
  11. double thirdDogg = Double.parseDouble(scanner.nextLine());
  12.  
  13. double total = days * (firstDogg + secondDogg + thirdDogg);
  14.  
  15. if (total > kg) {
  16. System.out.printf("%.0f more kilos of food are needed.", Math.ceil(total - kg));
  17. } else {
  18. System.out.printf("%.0f kilos of food left.", Math.floor(kg - total));
  19. }
  20.  
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment